math docs
    Preparing search index...

    Function decomposePolygon2Quality

    • Decomposes a simple polygon into the (near-)minimum number of convex sub-polygons. Produces fewer pieces than decomposePolygon2Quick but is much slower (~O(n⁴)) — use only for small polygons. Input winding is normalised internally, so either winding is accepted.

      Parameters

      • vertices: number[]

        polygon vertices as a flat array [x0, y0, x1, y1, ...]

      • n: number

        number of vertices to read from vertices

      Returns number[][]

      an array of convex sub-polygons, each a flat [x0, y0, ...] array (CCW)