CPolygon:PtInside


The PtInside method tests whether a point is interior to the CPolygon. The tests are made using <= or >= so that a point exactly on a CPolygon boundary is considered to be inside.

Syntax

bSuccess = CPolygon:PtInside( CPoint )

bSuccess = CPolygon:PtInside( x, y )

where

    x, y are the point coordinates.

    CPoint is a CPoint object.

    bSuccess is returned true if the point is inside the rectangle, otherwise false.

Examples

The following script tests whether the point (225,300) is inside the CPolygon:

x = { 1, 2, 3, 4, 3, 1, -5, 2 }

-- create a table of x values

y = { 4, 6, 1, 2, -7, 4, 5, 2 }

-- create a table of y values

P = NewPolygon( x, y )

-- create a CPolygon object

pt = NewPoint( -4.5,-2.225 )

 

test = P:PtInside( pt )

-- returns test = true or false

Printf( "Inside= %d\n", test)

-- result: Inside = 0

Related Topics

NewPolygon function

CPolygon class

CRect:PtInside