Module rational

Module rational 

Source
Expand description

Exact (BigRational) predicate tier — the correctness ground truth and the cascade’s last-resort exact fallback. f64 coordinates are exactly representable as BigRational, so every sign here is mathematically exact.

Functions§

cmp_along
Exact sign of (a − b)·u — order two points along direction u, over ANY Explicit/Lpi/Tpi mix (generalises lpi_compare_along). With a=λa/da, b=λb/db: (a−b)·u = ((λa·u)·db − (λb·u)·da)/(da·db).
cmp_lex
Exact lexicographic total order on points (x, then y, then z), over any mix of Explicit/Lpi/Tpi. Zero ⇔ the two points are EXACTLY coincident — this is the interner’s symbolic vertex-identity test (no float weld). A strict total order: antisymmetric, transitive (proven by property test).
lpi_compare_along
Exact sign of (proj_u(l1) − proj_u(l2)) where proj_u(X)=X·u — i.e. order two LPI points along direction u. proj = (λ·u)/d, so the sign is assemble_sign(sign((λ1·u)·d2 − (λ2·u)·d1), &[sign(d1), sign(d2)]).
lpi_lambda
LPI λ-construction (exact): the implicit point is (λx/d, λy/d, λz/d). Line PQ ∩ plane RST: parametrise X = P + τ·(Q−P); on-plane gives (P−R)·(SR×TR) + τ·(Q−P)·(SR×TR) = 0, i.e. n + τ·d = 0, so τ = −n/d and λ = d·P − n·(Q−P) (the MINUS is load-bearing — + lands off the plane; verified by tritri::edge_crossing_lpi_lies_exactly_on_the_plane). qp=Q−P; sr=S−R; tr=T−R; pr=P−R; d=det3(qp,sr,tr); n=det3(pr,sr,tr).
lpi_orient2d
Exact orient2d(p1=LPI, b, c) (b,c explicit), projected after axis.
lpi_orient3d
Exact orient3d(p1=LPI, p2, p3, p4) with p2,p3,p4 explicit.
lpi_point
The materialised LPI point λ/d (exact). Used by the oracle test that independently checks the homogenised form in lpi_orient3d.
orient2d_2i
orient2d with TWO implicit points (a,b) and one explicit (c), projected after axis. orient2d = Λ′/(d1·d2) with Λ′ = (λ1_i−d1·c_i)(λ2_j−d2·c_j) − (λ1_j−d1·c_j)(λ2_i−d2·c_i); both denominators are odd → den_signs = [sign(d1), sign(d2)].
orient2d_3i
orient2d with THREE implicit points (a,b,c), projected after axis, based on a: Λ′ = (d1·λ2_i−d2·λ1_i)(d1·λ3_j−d3·λ1_j) − (d1·λ2_j−d2·λ1_j)(d1·λ3_i−d3·λ1_i). D′ = d1²·d2·d3, so the squared d1 is dropped → den_signs = [sign(d2), sign(d3)].
orient2d_exact
Exact orient2d on the two axes remaining after dropping axis.
orient2d_exact_pt
Oracle cross-check: orient2d with the first arg already materialised.
orient3d_exact
Exact explicit orient3d — Shewchuk’s sign convention (matches geometry_predicates::orient3d).
orient3d_exact_pt
Oracle cross-check: orient3d with the first argument already materialised (the exact LPI point). Independent of the homogenisation above — the two MUST agree, which is what proves the Λ′/flip construction is correct.
tpi_lambda
TPI λ-construction (exact) via Cramer on the three plane equations nᵢ·x = cᵢ, with nᵢ=(Bᵢ−Aᵢ)×(Cᵢ−Aᵢ), cᵢ=nᵢ·Aᵢ (un-normalised → all polynomials, no sqrt). Cite: Attene 2020 §4. d=det3(n1,n2,n3), λ = the Cramer numerators (column k replaced by (c1,c2,c3)).
tpi_orient2d
Exact orient2d(p1=TPI, b, c) (b,c explicit), projected after axis.
tpi_orient3d
Exact orient3d(p1=TPI, p2, p3, p4) with p2,p3,p4 explicit.
tpi_point
Materialised TPI point λ/d (exact) — for the oracle cross-check.