earclip_polygon

compas.geometry.earclip_polygon(polygon)[source]

Triangulate a polygon using the ear clipping method. The polygon is assumed to be planar and non-self-intersecting and position on XY plane. The winding direction is checked. If the polygon is not oriented counter-clockwise, it is reversed.

Parameters:
polygoncompas.geometry.Polygon

A polygon defined by a sequence of points.

Returns:
list[[int, int, int]]

A list of triangles referencing the points of the original polygon.

Raises:
ValueError

If no ears were found for triangulation.

IndexError

If no more ears were found for triangulation.