Vec3

:= []

Arithmetic on 3D vectors. The record has the same shape as Vocabulary.Vec3, so you can pass one where the other goes.

zero : Vec3

(0, 0, 0).

one : Vec3

(1, 1, 1), a scale that changes nothing.

add : Vec3, Vec3 -> Vec3

a + b, one axis at a time.

sub : Vec3, Vec3 -> Vec3

a - b, one axis at a time.

neg : Vec3 -> Vec3

The vector that points the other way.

scale : Vec3, F32 -> Vec3

Multiplies each axis by s.

dot : Vec3, Vec3 -> F32

The dot product.

cross : Vec3, Vec3 -> Vec3

The cross product, right-handed: cross(x, y) is z.

normalize : Vec3 -> Vec3

The vector with length 1 in the same direction. Zero stays zero, so you never divide by a zero length.

lerp : Vec3, Vec3, F32 -> Vec3

The point a fraction t of the way from a to b. t of 0 gives a and 1 gives b.

Vec3 : { x : F32, y : F32, z : F32 }

A point or a direction in 3D.