API Reference › Vector
namespace

Vector

2D vector math for positions, velocities, and directions. A Vector is a pair of Q16.16 fixed components packed into one value, so it is copied by value and never allocates. Every operation is deterministic integer fixed-point — bit-identical on every platform, the same guarantee the rest of the runtime gives. Arguments are positional; angles are in radians.

Vector.make(x, y) -> VectorBuild a vector from x and y components.Vector.zero() -> VectorThe zero vector, (0, 0).Vector.x(v) -> fixedThe x component of a vector.Vector.y(v) -> fixedThe y component of a vector.Vector.add(a, b) -> VectorComponent-wise sum a + b.Vector.sub(a, b) -> VectorComponent-wise difference a - b.Vector.scale(v, s) -> VectorScale a vector by a scalar.Vector.dot(a, b) -> fixedThe dot product of two vectors.Vector.length(v) -> fixedThe length (magnitude) of a vector.Vector.distance(a, b) -> fixedThe distance between two points.Vector.normalize(v) -> VectorA unit vector in the same direction.Vector.lerp(a, b, t) -> VectorLinear interpolation between two vectors.Vector.rotate(v, angle) -> VectorRotate a vector by an angle in radians.Vector.angle(v) -> fixedThe angle of a vector in radians.Vector.from_angle(a) -> VectorA unit vector pointing at an angle.
← All symbols