Point.in_polygon

Point.in_polygon(polygon, convex=None)[source]

Determine if the point lies inside the given polygon.

Parameters
  • polygon (compas.geometry.Polygon or list of points.) – The polygon.

  • convex ({None, True, False}, optional) – Is the polygon convex. If None, determine if the polygon is convex. If False, use the non-convex algorithm. If True, use the convex algorithm.

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