Skip to main content

Module fixed

Module fixed 

Source
Expand description

Fixed-width exact predicate tier — the FAST exact arithmetic between the interval filter and the BigRational fallback.

num-rational is correct but ~3ms/call (heap-allocated BigInt + the Ratio wrapper on every op). The orient predicates are sign-invariant under uniform positive coordinate scaling, so on-grid coords (the f32-snap grid, k/2^16) scale to EXACT i64 integers and the whole lambda/determinant computes in stack-allocated bnum integers — no heap, no GCD. Every op is CHECKED: an overflow (the chosen width is too narrow) OR an off-grid coord returns None.

TIERED WIDTH: the same predicate is generated (by the fixed_impl! macro) at I256 / I512 / I1024. The public dispatch tries the NARROWEST first — most LPI predicates on building-scale coords fit I256 (4× faster than I1024) — and escalates on overflow. So the result is always a sign identical to BigRational, or a deferral up the cascade and finally to BigRational.

DUAL SCALE (crack-family fix): the exact-plane lift in mesh_bridge welds near-coplanar cutter vertices onto host planes at the FINER k/2^36 grid (2^16 snap grid × the 2^20 α,β quantization). Those coordinates fail the coarse gi fract check and previously fell to the ~3 ms BigRational tier on EVERY predicate. The cascade therefore carries a second, fine-scale family (f256/f512/f1024/f2048, gi scale 2^36) tried only after the coarse family declines — orientation predicates are sign-invariant under uniform positive scaling, so a per-call uniform scale is exactly equivalent. The extra f2048 rung exists because second-order TPI×TPI products at the fine scale reach ≈1340 bits (overflow I1024). Coarse-grid inputs keep resolving in the unchanged coarse family ⇒ zero cost on the common path.

Functions§

cmp_along
cmp_lex
cmp_lex_from_lam
Lexicographic compare of two interned points from their cached lambdas.
indirect_orient2d
indirect_orient3d
lambda1024
The I512 homogeneous lambda of an implicit point (the value cached per Vid).
orient2d_2i
orient2d_3i
orient2d_from_lam
2-D orientation of three interned points from their cached lambdas.
point_to_f64
Materialize an implicit point to f64 via the FIXED-width (I1024) homogeneous lambda — the fast path for the BigRational rational::point_of. The lambda is computed in the gi-scaled domain (coords × 2^16), so the real coordinate is lambda[k] / (d · 2^16). Returns None on off-grid coords / overflow, where the caller falls back to the exact BigRational materialization. Used for the classifier centroids AND the output verts (the dominant per-op cost).

Type Aliases§

Lam