Triangulator

A simple implementation of the ear cutting algorithm to triangulate simple polygons without holes.

If the input polygon is not simple (self-intersects), there will be output but it is of unspecified quality (garbage in, garbage out).

If the polygon vertices are very large or very close together then isClockwise may not be able to properly assess the winding (because it uses floats). In that case the vertices should be adjusted, eg by finding the smallest X and Y values and subtracting that from each vertex.

Ported from: EarClippingTriangulator

Author

Colton Daily

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun computeTriangles(vertices: FloatArray, offset: Int = 0, count: Int = vertices.size): ShortArrayList

Triangulates the given (convex or concave) simple polygon to a list of triangle vertices.