Skip to main content

Function: calculateCentroid()

calculateCentroid(vertices): Vector2

Defined in: physics/shapes/polygon-math.ts:30

Calculates the centroid (center of mass, for a uniform-density polygon) of a simple polygon.

Parameters

vertices

readonly Vector2[]

The polygon's vertices, in order.

Returns

Vector2

The centroid of the polygon.