ladybug_geometry.triangulation module¶
Core triangulation functions used by various geometry modules.
The functions here are derived from the earcut-python library available at https://github.com/joshuaskelly/earcut-python
The earcut-python library is, itself, a pure Python port of the earcut JavaScript triangulation library maintained by Mapbox. The original project can be found at https://github.com/mapbox/earcut
The version here is based off of the JavaScript earcut 2.1.1 release, and is functionally identical.
- ladybug_geometry.triangulation.earcut(data, hole_indices=None, dim=2)[source]¶
Triangulate a list of vertices that make up a shape, either with or without holes.
- Parameters
data – A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, …].
hole_indices – A flat array of the starting indices for each hole. For example, [5, 8] for a 12-vertex input would mean one hole with vertices 5-7 and another with 8-11. If a single vertex is passed as as a hole, Earcut treats it as a Steiner point. If None, no holes will be assumed for the shape. (Default: None).
dim – An integer for the number of coordinates per vertex in the input array. For example, 3 means each vertex exists in 3D space with XX, Y, Z coordinates. (Default: 2 for 2D coordinates).