Adjust rotEPS for single precision in mju_mat2Rot.

This change defines rotEPS as 1e-6f when mjUSESINGLE is defined, and 1e-9 otherwise. With the larger epsilon for single precision, the algorithm converges in fewer iterations, allowing the test assertion for maximum iterations to be simplified to a constant 150.

PiperOrigin-RevId: 959070496
Change-Id: I4f6fae056cd71955d3921c01a9929af2cdd81fac
This commit is contained in:
Alessio Quaglino
2026-08-04 09:37:44 -07:00
committed by Copybara-Service
parent b3ef7a8c2f
commit 63c7175ed5
2 changed files with 11 additions and 8 deletions
+3 -4
View File
@@ -218,9 +218,8 @@ TEST_F(Mat2RotTest, RotationFromArbitraryMatrix) {
// calculate rotational part of the matrix
mjtNum quat[4] = {1, 0, 0, 0};
int niter = mju_mat2Rot(quat, mat);
EXPECT_THAT(quat, Pointwise(MjNear(1e-8, 1e-6), target));
int max_iter = static_cast<int>(MjTol(150, 500));
EXPECT_LE(niter, max_iter);
EXPECT_THAT(quat, Pointwise(MjNear(1e-8, 1e-5), target));
EXPECT_LE(niter, 150);
}
TEST_F(Mat2RotTest, IdentityFromRandomRotation) {
@@ -244,7 +243,7 @@ TEST_F(Mat2RotTest, IdentityFromRandomRotation) {
mju_normalize4(quat);
EXPECT_LE(mju_mat2Rot(quat, mat), 40);
mju_quat2Mat(res, quat);
EXPECT_THAT(res, Pointwise(MjNear(1e-6, 1e-6), mat));
EXPECT_THAT(res, Pointwise(MjNear(1e-6, 1e-5), mat));
}
}