Class PolygonTriangulator
Ear-clipping triangulation of a simple ring in mercator space, run once per shape, never per frame.
public static class PolygonTriangulator
- Inheritance
-
objectPolygonTriangulator
Methods
IsSimpleRing(IReadOnlyList<MercatorPoint>)
True if the closed ring is a simple polygon: no zero-length edge, no pair of non-adjacent edges sharing any point, and no vertex where the ring doubles back along the edge it arrived on.
public static bool IsSimpleRing(IReadOnlyList<MercatorPoint> ring)
Parameters
ringIReadOnlyList<MercatorPoint>Closed vertices in normalized mercator. Null or under three points is not simple.
Returns
- bool
True only when every extra gate in the summary passes; false otherwise.
Remarks
Collinearity uses an exact-zero cross product: a tolerance would refuse valid rings whose vertices are merely nearly collinear, and a real crossing still fails the strict sign test.
Triangulate(IReadOnlyList<MercatorPoint>, List<int>)
Fills triangleIndices with vertex-index triples,
or clears it and returns false.
public static bool Triangulate(IReadOnlyList<MercatorPoint> ring, List<int> triangleIndices)
Parameters
ringIReadOnlyList<MercatorPoint>Ring vertices in normalized mercator. Null or under three points fails. Winding direction does not matter.
triangleIndicesList<int>Cleared first, then filled with triples of ring indices. Empty on every refusal.
Returns
- bool
True for a simple ring of at least three points with non-zero area that ear clipping finished. False when the ring is under three points, has no area, intersects itself, or ear clipping stops.