dot(a: V3, b: V3) → number return a
| arg | type | description |
|---|
| a | V3 | |
| b | V3 | |
cross(a: V3, b: V3) → V3
| arg | type | description |
|---|
| a | V3 | |
| b | V3 | |
add(a: V3, b: V3, s: number?) → V3
| arg | type | description |
|---|
| a | V3 | |
| b | V3 | |
| s | number? | |
sub(a: V3, b: V3) → V3 return
| arg | type | description |
|---|
| a | V3 | |
| b | V3 | |
qrot(q: { number }, v: V3) → V3
Rotate `v` by quaternion `q` {x,y,z,w}.
| arg | type | description |
|---|
| q | { number } | |
| v | V3 | |
qunrot(q: { number }, v: V3) → V3
Inverse-rotate `v` by quaternion `q`.
| arg | type | description |
|---|
| q | { number } | |
| v | V3 | |
rayPart(part: any, o: V3, d: V3) → void
Ray (origin `o`, unit direction `d`, bot space) against one part's oriented box. Returns the entry distance and the local axis index (1..3) and sign of the face it enters through, or nil.
| arg | type | description |
|---|
| part | any | |
| o | V3 | |
| d | V3 | |
parts(parts: { any }, o: V3, d: V3, skip: { [string]: boolean }?) → any
The nearest part a bot-space ray hits: { id, part, t, point, normal (bot space, unit) }, or nil. `skip` is a set of ids to ignore.
| arg | type | description |
|---|
| parts | { any } | |
| o | V3 | |
| d | V3 | |
| skip | { [string]: boolean }? | |
floor(o: V3, d: V3, y: number?) → any
Where a bot-space ray meets the floor plane y = `y` (default 0): { point, normal = up, t } or nil.
| arg | type | description |
|---|
| o | V3 | |
| d | V3 | |
| y | number? | |
eulerFromBasis(X: V3, Y: V3, Z: V3) → V3
Euler {pitch, yaw, roll} (degrees, bots.parts order: yaw, then pitch, then roll) of the rotation taking local X/Y/Z onto the given orthonormal bot-space axes.
| arg | type | description |
|---|
| X | V3 | |
| Y | V3 | |
| Z | V3 | |
clean(a: number) → number
| arg | type | description |
|---|
| a | number | |
basisFromNormal(mode: string, n: V3) → void
| arg | type | description |
|---|
| mode | string | |
| n | V3 | |
support(size: V3, rot: V3, n: V3) → number
Half the extent of a part (size, rot) along bot-space unit direction `n`.
| arg | type | description |
|---|
| size | V3 | |
| rot | V3 | |
| n | V3 | |
place(typeName: string, size: V3, hit: any, snap: ((number) → void
Where a new part of `typeName` (with `size`) sits on `hit` ({ point, normal }) — flush on the face, turned to it (wheels axle-out on side faces, plates lying on faces, weapons facing out). `snap(v)` snaps a coordinate along the face. Returns pos, rot.
| arg | type | description |
|---|
| typeName | string | |
| size | V3 | |
| hit | any | |
| snap | ((number | |
closestOnAxis(o: V3, d: V3, p0: V3, axis: V3) → number
Parameter along a line (point `p0`, unit `axis`) of the point closest to a ray (o, d).
| arg | type | description |
|---|
| o | V3 | |
| d | V3 | |
| p0 | V3 | |
| axis | V3 | |
rayPlane(o: V3, d: V3, p0: V3, n: V3) → V3
Where a ray meets the plane through `p0` with normal `n`, or nil.
| arg | type | description |
|---|
| o | V3 | |
| d | V3 | |
| p0 | V3 | |
| n | V3 | |
segDist(px: number, py: number, ax: number, ay: number, bx: number, by: number) → number
Distance (pixels) from point (px, py) to the screen segment a..b.
| arg | type | description |
|---|
| px | number | |
| py | number | |
| ax | number | |
| ay | number | |
| bx | number | |
| by | number | |