ifc_lite_geometry/math/mod.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! The cross-crate math home: vectors, 4x4 matrices, AABBs and the Z-up to
6//! Y-up frame, over plain arrays (#7772, charter #7670), plus the plane kit
7//! [`v2`] and its exact predicates (`geom2d`, #7773).
8//!
9//! `nalgebra` stays geometry's interior type. Every cross-crate signature is
10//! already an array (`InstanceMeta.transform`, `origin`, `local_bounds`), so
11//! this module speaks `[f64; 3]` and row-major `[f64; 16]`, with exact bridges
12//! to `Matrix4<f64>` in [`mat4`]. The one struct is [`aabb::Aabb3`], because a
13//! box carries an invariant (the empty sentinel, well-formedness) that a tuple
14//! cannot.
15//!
16//! # Conventions (the contract the tests pin)
17//!
18//! - **f64 throughout.** f32 appears only at the named boundary casts
19//! ([`mat4::to_f32`], [`mat4::to_col_major_f32`]) and in the exact widening
20//! [`aabb::Aabb3::from_f32_positions`]. Internal void folds also retain their
21//! native f32 precision through `aabb::Aabb3f32`.
22//! - **Row-major** `[f64; 16]` (`m[r * 4 + c]`). A column-major array enters
23//! only through [`mat4::transpose`], [`mat4::col_major_array`] or
24//! [`mat4::transform_vector`]'s documented `Mᵀ·v` identity.
25//! - **No FMA, no `mul_add`.** Every sum is written out left to right
26//! (`a0*b0 + a1*b1 + a2*b2`). The operation order is part of the contract:
27//! `mesh_determinism` and the corpus fingerprints pin outputs that pass
28//! through these functions, and the kernel relies on it.
29//! - **NaN behaviour is stated per function.** `min`/`max` folds skip NaN
30//! (`f64::min`), `normalize` refuses a non-finite length.
31//! - **Thresholds are arguments.** `normalize` takes its `min_len`; the
32//! values callers pass are named, with units, in [`tol`] (F2c, #7774).
33
34pub mod aabb;
35pub mod frame;
36pub(crate) mod geom2d;
37pub mod mat4;
38pub(crate) mod normals;
39pub mod v2;
40pub mod v3;
41pub mod tol;
42
43#[cfg(test)]
44mod aabb_tests;
45#[cfg(test)]
46mod canonical_parity_tests;
47#[cfg(test)]
48mod frame_tests;
49#[cfg(test)]
50mod mat4_tests;
51#[cfg(test)]
52mod normals_tests;
53#[cfg(test)]
54mod v2_tests;
55#[cfg(test)]
56mod v3_tests;
57#[cfg(test)]
58mod tol_tests;