functionisInsidePolygon
Determines whether a point is inside a polygon
Information
Syntax
z = isInsidePolygon (point, polygon, eps);
Description
Determines whether point is inside polygon.
point is given by its x and y coordinates.
polygon is given by a vector of points, each point being given by its x and y coordinates.
If point is inside polygon, then z > + 0.5. If point is outside polygon, then - 0.5 < z < + 0.5. If it cannot be decided whether point is inside or outside polygon, then z < - 0.5.
The result is undecided when point is too close to polygon, the tolerance being given by eps. The default is eps = 1e-4.
Example
z = isInsidePolygon ({-23, -7}, {{-92,-4},{-64,24},{-60,-14},{-42,24},{-24,-34},{60,-44},{2,8},{44,18},{8,84},{-74,82}});
returns z > 0.5; (cf. graphics in diagram layer)
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[2] | point | Point | |
| Real[:,2] | polygon | Polygon | |
| Real | tolerance | 0 | Tolerance |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | insidePolygon | > 0.5: point is inside polygon. > -0.5 and < 0.5: point is outside polygon: < -0.5: undecided |