Skip to main content

Module vec3

Module vec3 

Source
Expand description

The crate’s shared 3-component vector math. Every module that needs a dot, cross, or component-wise op reaches for these rather than redeclaring them.

Normalisation deliberately stays with its caller: the degenerate-input rule differs by site (a fallback axis vs None vs a clamped length), and folding those together would change behavior at grazing inputs.

Functions§

add
Component-wise sum, a + b.
cross
Cross product.
dot
Dot product.
length
Euclidean length.
lerp
Component-wise linear interpolation from a to b.
scale
Every component scaled by s.
sub
Component-wise difference, a - b.
vec3_add
Accumulate src into dst in place. Used by the smooth-normal passes, which sum every incident face normal per vertex before normalising once.
vec3_face_normal
Newell-style face normal from three CCW positions. Shared with the cook generators’ smooth-normal pass.
vec3_normalise
Unit-length n, falling back to +Y when it is too short to have a direction.