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 Vec2 objects

  • holes – 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[UVec], holes: Iterable[Iterable[UVec]] | None = None) Iterator[Sequence[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 objects

  • holes – 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