Skip to main content

Function: findClosestFace()

findClosestFace(vertices, normals, localCenter, radius): FaceSeparation | null

Defined in: physics/collision/circle-polygon-contact.ts:58

Finds the polygon face with the largest separation from localCenter (a circle's center, in the polygon's own local space), for use as the circle's reference face. Returns null if the circle's radius cannot reach any face, meaning the shapes do not overlap.

Parameters

vertices

readonly Vector2[]

The polygon's vertices, in its own local space.

normals

readonly Vector2[]

The polygon's outward-facing edge normals, matching vertices.

localCenter

Vector2

The circle's center, in the polygon's local space.

radius

number

The circle's radius.

Returns

FaceSeparation | null

The closest face and its separation, or null if the shapes cannot overlap.