math docs
    Preparing search index...

    Function centroid

    • Computes the area-weighted centroid (center of mass) of the polygon. For a degenerate (zero-area) polygon this falls back to the average of the vertices.

      Parameters

      • out: vec2.Vec2

        the vector to store the centroid

      • vertices: number[]

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

      • n: number

        number of vertices to read from vertices

      Returns vec2.Vec2

      out