Skip to content

Route eigenvalue trigonometry through ComplexField under std - #10

Open
zgsrc wants to merge 1 commit into
dimforge:mainfrom
zgsrc:eigen3-libm-routing
Open

zgsrc wants to merge 1 commit into
dimforge:mainfrom
zgsrc:eigen3-libm-routing

Conversation

@zgsrc

@zgsrc zgsrc commented Oct 5, 2026

Copy link
Copy Markdown

Fixes #9.

With the libm feature on (which parry3d/rapier3d enhanced-determinism enable), SymmetricEigen3::eigenvalues still called the platform math library in a std build: r.acos() and phi.cos() resolve to the inherent f64 methods, and the ComplexField import that would route them through simba is compiled only without std. Results therefore differed across platforms (observed: macOS x86-64 vs arm64/Linux x86-64) whenever a non-diagonal inertia tensor reached the trigonometric branch, which Rapier hits for any compound or rotated collider.

This calls the three functions through ComplexField explicitly. Without the libm feature they still resolve to the standard library, so nothing changes for other users.

Also adds a test, gated on libm + std, that compares the eigenvalues bit for bit with the same closed form evaluated through the libm crate (new libm dev-dependency), and a changelog entry.

Verified: cargo check for default, --all-features, --no-default-features --features libm, --features libm; cargo test --all-features (57 tests). In our project this change made a Rapier scene with a rotated compound collider bit-identical across macOS arm64, macOS x86-64 and Linux x86-64; the other shapes already agreed.

🤖 Generated with Claude Code

`SymmetricEigen3::eigenvalues` called `acos` and `cos` as inherent float
methods, which resolve to the platform math library in a `std` build even
with the `libm` feature on; the `ComplexField` import that would route
them through simba is compiled only without `std`. Inertia
diagonalization in Rapier therefore differed between platforms with
`enhanced-determinism` enabled (dimforge#9).

Call the functions through `ComplexField` explicitly. Without the `libm`
feature they still resolve to the standard library, so nothing changes
for other users. Adds a test, gated on `libm` and `std`, that compares
the result bit for bit with the closed form evaluated through `libm`.

Fixes dimforge#9

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SymmetricEigen3::eigenvalues calls platform acos/cos in std builds, breaking enhanced-determinism

1 participant