Triangulation¶
Triangulation module: ezdxf.math.triangulation
- ezdxf.math.triangulation.mapbox_earcut_2d(exterior: Iterable[UVec], holes: Iterable[Iterable[UVec]] | None = None) list[Sequence[Vec2]]¶
Mapbox triangulation algorithm with hole support for 2D polygons.
Implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn’t guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data.
Source: https://github.com/mapbox/earcut
- Parameters:
exterior – exterior polygon as iterable of
Vec2objectsholes – iterable of holes as iterable of
Vec2objects, a hole with single point represents a Steiner point.
- Returns:
yields the result as 3-tuples of
Vec2objects
- ezdxf.math.triangulation.mapbox_earcut_3d(exterior: Iterable[UVec], holes: Iterable[Iterable[UVec]] | None = None) Iterator[tuple[Vec3, Vec3, Vec3]]¶
Mapbox triangulation algorithm with hole support for flat 3D polygons.
Implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn’t guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data.
Source: https://github.com/mapbox/earcut
- Parameters:
exterior – exterior polygon as iterable of
Vec3objectsholes – iterable of holes as iterable of
Vec3objects, a hole with single point represents a Steiner point.
- Returns:
yields the result as 3-tuples of
Vec3objects- Raises:
TypeError – invalid input data type
ZeroDivisionError – normal vector calculation failed