Triangulation¶
Triangulation module: ezdxf.math.triangulation
- ezdxf.math.triangulation.mapbox_earcut_2d(exterior: Iterable[Union[Sequence[float], Vec2, Vec3]], holes: Optional[Iterable[Iterable[Union[Sequence[float], Vec2, Vec3]]]] = None) list[Sequence[ezdxf.math._vector.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
Vec2
objectsholes – iterable of holes as iterable of
Vec2
objects, a hole with single point represents a Steiner point.
- Returns
yields the result as 3-tuples of
Vec2
objects
- ezdxf.math.triangulation.mapbox_earcut_3d(exterior: Iterable[Union[Sequence[float], Vec2, Vec3]], holes: Optional[Iterable[Iterable[Union[Sequence[float], Vec2, Vec3]]]] = None) Iterator[tuple[ezdxf.math._vector.Vec3, ezdxf.math._vector.Vec3, ezdxf.math._vector.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
Vec3
objectsholes – iterable of holes as iterable of
Vec3
objects, a hole with single point represents a Steiner point.
- Returns
yields the result as 3-tuples of
Vec3
objects- Raises
TypeError – invalid input data type
ZeroDivisionError – normal vector calculation failed