Examples
import { Vector2 } from '@wimaengine/math'
import { circleContains } from '@wimaengine/narrowphase'
const center = new Vector2(0, 0)
circleContains(center, 2, new Vector2(1, 1)) // true
circleContains(center, 2, new Vector2(2, 1)) // falseFunction
circleContains(position: Vector2, radius: number, point: Vector2): booleanTests whether a point is inside or on the boundary of a circle.
The distance is compared as squared values, so the helper avoids taking a
square root. A point exactly on the circumference is contained. A radius of
0 contains only the center, while a negative radius is not rejected and
behaves like the corresponding positive radius because it is squared.
The vectors are read but not modified.
import { Vector2 } from '@wimaengine/math'
import { circleContains } from '@wimaengine/narrowphase'
const center = new Vector2(0, 0)
circleContains(center, 2, new Vector2(1, 1)) // true
circleContains(center, 2, new Vector2(2, 1)) // false