Module math

Module math 

Source
Expand description

Vector, matrix, frame and AABB math over arrays: the one cross-crate home (nalgebra stays geometry’s interior type). See the module docs for the op-order and FMA contract. The cross-crate math home: vectors, 4x4 matrices, AABBs and the Z-up to Y-up frame, over plain arrays (#7772, charter #7670), plus the plane kit [v2] and its exact predicates (geom2d, #7773).

nalgebra stays geometry’s interior type. Every cross-crate signature is already an array (InstanceMeta.transform, origin, local_bounds), so this module speaks [f64; 3] and row-major [f64; 16], with exact bridges to Matrix4<f64> in [mat4]. The one struct is [aabb::Aabb3], because a box carries an invariant (the empty sentinel, well-formedness) that a tuple cannot.

§Conventions (the contract the tests pin)

  • f64 throughout. f32 appears only at the named boundary casts ([mat4::to_f32], [mat4::to_col_major_f32]) and in the exact widening [aabb::Aabb3::from_f32_positions]. Internal void folds also retain their native f32 precision through aabb::Aabb3f32.
  • Row-major [f64; 16] (m[r * 4 + c]). A column-major array enters only through [mat4::transpose], [mat4::col_major_array] or [mat4::transform_vector]’s documented Mᵀ·v identity.
  • No FMA, no mul_add. Every sum is written out left to right (a0*b0 + a1*b1 + a2*b2). The operation order is part of the contract: mesh_determinism and the corpus fingerprints pin outputs that pass through these functions, and the kernel relies on it.
  • NaN behaviour is stated per function. min/max folds skip NaN (f64::min), normalize refuses a non-finite length.
  • Thresholds are arguments. normalize takes its min_len; the values callers pass are named, with units, in [tol] (F2c, #7774).

Modules§

aabb
Axis-aligned boxes over [f64; 3].
frame
The IFC Z-up to WebGL Y-up frame, defined once.
mat4
Row-major 4x4 matrices over [f64; 16] (m[r * 4 + c]), plus exact bridges to nalgebra::Matrix4<f64> and the f32 boundary casts.
tol
The tolerance catalogue (F2c, #7774, charter #7670): every named numeric tolerance the geometry stack shares, with the unit it is measured in and why it has that value.
v2
Plane vectors and ring primitives over [f64; 2]: the one home for the 2D kit that geom2d, bool2d, scan_outline, the triangulator, the export plates and the processing PDF/scan code each used to carry a copy of (#7773). Every function is FMA-free with the op order written out; see the module conventions.
v3
3-vectors over [f64; 3]. Every function is FMA-free with the op order written out; see the module conventions.