Point.in_polygon

Point.in_polygon(polygon)[source]

Determine if the point lies inside the given polygon.

For this test, the point and polygon are assumed to lie in the XY plane. The Z coordinates of the point and of the points of the polygon are ignored. If the point and/or polygon do not lie in the XY plane, the result of this test is meaningless. It is up to the user to apply the necessary transformations beforehand.

The polygon can be convex or concave.

Parameters:
polygonsequence[point] | compas.geometry.Polygon

The polygon.

Returns:
bool

True, if the point lies in the polygon. False, otherwise.

Examples

>>> from compas.geometry import Polygon
>>> poly = Polygon([Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0), Point(0.0, 1.0, 0.0)])
>>> point = Point(0.5, 0.5, 0.0)
>>> point.in_polygon(poly)
True