v(x: number, y: number, z: number) → Vec return
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
add(a: Vec, b: Vec) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
sub(a: Vec, b: Vec) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
scale(a: Vec, s: number) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| s | number | |
dot(a: Vec, b: Vec) → number return a
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
cross(a: Vec, b: Vec) → Vec
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
len(a: Vec) → number return math
dist(a: Vec, b: Vec) → number return G
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
vec(v: any) → Vec
Accept { x, y, z }, { x = , y = , z = } or a vector.
wrap(a: number) → number
Wrap an angle into (-pi, pi].
| arg | type | description |
|---|
| a | number | |
rotY(v: Vec, yaw: number) → Vec
Turn a local vector by a yaw (a yaw of 0 keeps +Z; pi/2 turns +Z to +X).
| arg | type | description |
|---|
| v | Vec | |
| yaw | number | |
rotX(v: Vec, a: number) → Vec
| arg | type | description |
|---|
| v | Vec | |
| a | number | |
rotZ(v: Vec, a: number) → Vec
| arg | type | description |
|---|
| v | Vec | |
| a | number | |
quatYaw(yaw: number) → void
Quaternions as { x, y, z, w }.
| arg | type | description |
|---|
| yaw | number | |
quatMul(a: { number }, b: { number }) → void
| arg | type | description |
|---|
| a | { number } | |
| b | { number } | |
quatAxis(axis: Vec, a: number) → void
| arg | type | description |
|---|
| axis | Vec | |
| a | number | |
boxQuat(b: any) → void
The rotation of a catalog box (pitch about X, then roll about Z, then its own yaw) as a quaternion.
toWorld(pose: Pose, p: Vec) → Vec
A point in piece space carried to the world by a pose.
| arg | type | description |
|---|
| pose | Pose | |
| p | Vec | |
toLocal(pose: Pose, p: Vec) → Vec
| arg | type | description |
|---|
| pose | Pose | |
| p | Vec | |
boxLocal(b: any, v: Vec) → Vec
Turn a local vector the way a catalog box is turned inside its piece.
| arg | type | description |
|---|
| b | any | |
| v | Vec | |
obb(pose: Pose, b: any, shrink: number?) → OBB
The world OBB of catalog box `b` on a piece standing at `pose`, shrunk by `shrink` on every side.
| arg | type | description |
|---|
| pose | Pose | |
| b | any | |
| shrink | number? | |
obbOverlap(A: OBB, B: OBB) → boolean
Do two OBBs overlap? (separating axis test, 15 axes)
| arg | type | description |
|---|
| A | OBB | |
| B | OBB | |
closestOnObb(o: OBB, p: Vec) → Vec
The point of an OBB closest to `p`.
| arg | type | description |
|---|
| o | OBB | |
| p | Vec | |
pointInObb(o: OBB, p: Vec, pad: number?) → boolean
Is `p` inside an OBB grown by `pad` on every side?
| arg | type | description |
|---|
| o | OBB | |
| p | Vec | |
| pad | number? | |
rayObb(o: Vec, dir: Vec, box: OBB, maxDist: number?) → number
Ray (origin, unit direction) against an OBB: the distance to the entry point, or nil.
| arg | type | description |
|---|
| o | Vec | |
| dir | Vec | |
| box | OBB | |
| maxDist | number? | |
capsuleObb(base: Vec, height: number, radius: number, box: OBB) → boolean
Does a vertical capsule (feet at `base`, `height` tall, `radius` wide) overlap an OBB?
| arg | type | description |
|---|
| base | Vec | |
| height | number | |
| radius | number | |
| box | OBB | |
slopeOf(normal: Vec) → number
Angle in radians between a surface normal and straight up.
| arg | type | description |
|---|
| normal | Vec | |
snapTo(v: number, step: number, origin: number?) → number
Snap `v` to the nearest multiple of `step` (offset by `origin`).
| arg | type | description |
|---|
| v | number | |
| step | number | |
| origin | number? | |