Skip to main content

Module vec2

Module vec2 

Source
Expand description

2-D vector helpers.

Vec2 is a type alias over [f64; 2] so it is ABI-compatible with any [f64; 2] used elsewhere in the workspace.

Functions§

add
a + b.
cross
2-D cross product (scalar, = a × b z-component).
distance
Euclidean distance |a - b|.
dot
a · b.
lerp
Linear interpolation a + t * (b - a).
norm
|a|.
norm_squared
|a|².
normalize
Unit vector or [0, 0] if |a| is below machine epsilon.
rotate
Rotate v by angle radians (counter-clockwise).
scale
a * s.
sub
a - b.

Type Aliases§

Vec2
2-D vector in metres (or any consistent unit).