diff options
author | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2011-03-07 11:42:55 +0000 |
---|---|---|
committer | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2011-03-07 11:42:55 +0000 |
commit | 931edea57dbe44fd0bd5771f14bde498bc57d5b0 (patch) | |
tree | c4afda15352e18ad51f529861360067cd75d7675 /test/geo_quaternion.cpp | |
parent | bfcad536e85cb189936eef3dd8e62597281ab32b (diff) |
Tweak geo_quaternion test to squash intermittent failures.
Diffstat (limited to 'test/geo_quaternion.cpp')
-rw-r--r-- | test/geo_quaternion.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/geo_quaternion.cpp b/test/geo_quaternion.cpp index 948c58901..e5b64e939 100644 --- a/test/geo_quaternion.cpp +++ b/test/geo_quaternion.cpp @@ -72,7 +72,7 @@ template<typename Scalar, int Options> void quaternion(void) if((q1.coeffs()-q2.coeffs()).norm() > 10*largeEps) { - VERIFY(internal::isApprox(q1.angularDistance(q2), refangle, largeEps)); + VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(q1.angularDistance(q2) - refangle), Scalar(1)); } // rotation matrix conversion @@ -90,7 +90,15 @@ template<typename Scalar, int Options> void quaternion(void) // angle-axis conversion AngleAxisx aa = AngleAxisx(q1); VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1); - VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1); + + // Do not execute the test if the rotation angle is almost zero, or + // the rotation axis and v1 are almost parallel. + if (internal::abs(aa.angle()) > 5*test_precision<Scalar>() + && (aa.axis() - v1.normalized()).norm() < 1.99 + && (aa.axis() + v1.normalized()).norm() < 1.99) + { + VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1); + } // from two vector creation VERIFY_IS_APPROX( v2.normalized(),(q2.setFromTwoVectors(v1, v2)*v1).normalized()); |