Examples
import { Vector2 } from '@wimaengine/math'
import { Collider2D, shapeContains } from '@wimaengine/narrowphase'
const circle = Collider2D.circle(2)
shapeContains(circle, new Vector2(1, 1)) // trueFunction
shapeContains(shape: Collider2D, point: Vector2): booleanTests a point against the current representation of a Collider2D.
A shape whose type is Collider2D.Circle is interpreted using the engine’s
circle encoding: shape.vertices[0] is the center and
shape.vertices[1].x is the radius. Every other type is treated as a
polygon and passed to verticesContain, which expects clockwise,
convex vertices. Circle and polygon boundaries are both considered
contained.
The helper reads type and vertices only. It does not update the collider,
inspect its geometry or angle, or validate a manually assembled shape.
import { Vector2 } from '@wimaengine/math'
import { Collider2D, shapeContains } from '@wimaengine/narrowphase'
const circle = Collider2D.circle(2)
shapeContains(circle, new Vector2(1, 1)) // true