onemath
Deterministic math for .NET. Vectors, matrices, correctly rounded functions and exact predicates that give the same bits on every OS, CPU, runtime and thread count.
A quick look
The same answer, to the last bit, on x64, arm64 and WebAssembly. That is what keeps lockstep peers, replays and saved games in sync.
Getting startedusing RecursiveAI.OneMath; using RecursiveAI.OneMath.Predicates; double s = Math64.Sin(1e300); // correctly rounded int side = ExactPredicates.Orient2D(0, 0, 1, 0, 0.5, 1e-10); long raw = FixedBridge.FromDouble(1.5); // Q31.32
What it does
Correctly rounded functions
sin, cos, tan, the inverse functions, exp, log, pow, cbrt, hypot and the hyperbolic functions, in float and double. Each returns the representable number nearest the exact value.
Vectors, matrices, quaternions
Vector, matrix, quaternion, affine, rigid-transform and bounds types in float and double, with the evaluation order of every operation written down.
Exact predicates
Orient2D, Orient3D, InCircle, InSphere and segment classification return the sign of the exact value, so geometry code never contradicts itself.
A fixed-point bridge
Q31.32 raw values to and from double, exact within ±2^21, for hosts that keep world coordinates in fixed point.
Physics math
Inertia tensors of solids and compound bodies, and a symmetric 3x3 eigen decomposition for their principal axes.
Stable across 1.x
No 1.x release changes an existing result. A change that would alter one, even a more accurate one, ships as a new member or waits for 2.0.
One hash on every platform
A hash matrix runs fixed scenarios and compares their SHA-256 manifests across x64 with and without SIMD, one thread and all cores, NativeAOT, browser WebAssembly and macOS arm64. Each release must also reproduce every line of the previous release’s manifest. Only IEEE + - * / and square root decide a result, and an analyzer bans platform math and fused multiply-add at build time.
The package
- RecursiveAI.OneMath
Types, functions, predicates, the fixed-point bridge and physics math. No dependency beyond the .NET base class library. 1.0.0.
- Matrices
Column vectors, the opposite of System.Numerics.
FromSystemNumericsandToSystemNumericsconvert both ways. - Speed
Correct rounding costs time. In informal single-thread measurements it takes from about 3 times the platform’s
Mathfor sin to about 21 times for cosh. - Used by
onepath and onephysics build on it.
- .NET
.NET 10 on Windows, Linux, macOS and browser WebAssembly. NativeAOT and trimming are supported. MIT or Apache-2.0.