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 × bz-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
vbyangleradians (counter-clockwise). - scale
a * s.- sub
a - b.
Type Aliases§
- Vec2
- 2-D vector in metres (or any consistent unit).