Point.in_convex_polygon

Point.in_convex_polygon(polygon)[source]

Determine if the point lies inside the given convex 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 must be convex. However, the method will not check that this is indeed the case.

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

The polygon.

Returns:
bool

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

See also

in_polygon()

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_convex_polygon(poly)
True