Package limn.graphics

Class PolygonTriangulator

java.lang.Object
limn.graphics.PolygonTriangulator

public final class PolygonTriangulator extends Object
Ear-clipping triangulation of simple (non-self-intersecting) polygons, convex or concave, any winding. Support code for backends (and tested headlessly here); not meant as application API.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    signedArea(float[] xs, float[] ys, int offset, int count)
    Signed polygon area (positive = clockwise with y growing down).
    static int[]
    triangulate(float[] xs, float[] ys, int offset, int count)
    Triangulates the polygon (xs[offset + i], ys[offset + i]) for i < count.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • triangulate

      public static int[] triangulate(float[] xs, float[] ys, int offset, int count)
      Triangulates the polygon (xs[offset + i], ys[offset + i]) for i < count.
      Returns:
      triangle vertex indices relative to offset, 3 * (count - 2) entries on success; degenerate inputs (collinear rings, count < 3) may produce fewer triangles
    • signedArea

      public static float signedArea(float[] xs, float[] ys, int offset, int count)
      Signed polygon area (positive = clockwise with y growing down).