aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-12-16 16:50:30 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-12-16 16:50:30 +0100
commitf806c23012937f0acf55203dcb1f9d532bd0080b (patch)
treefa14f8bcc0af37f89a9da4f8c25d513f6356ef26 /test
parent99501a2c4c015a0f5a4a11d3cfbcdf1d3a39fe49 (diff)
Fix false negatives in geo_transformations unit tests
Diffstat (limited to 'test')
-rw-r--r--test/geo_transformations.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp
index e189217eb..042dd0329 100644
--- a/test/geo_transformations.cpp
+++ b/test/geo_transformations.cpp
@@ -99,10 +99,16 @@ template<typename Scalar, int Mode, int Options> void transformations()
Scalar a = internal::random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
Scalar s0 = internal::random<Scalar>(), s1 = internal::random<Scalar>();
+
+ while(v0.norm() < test_precision<Scalar>()) v0 = Vector3::Random();
+ while(v1.norm() < test_precision<Scalar>()) v1 = Vector3::Random();
VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
- VERIFY_IS_APPROX(cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
+ if(abs(cos(a)) > test_precision<Scalar>())
+ {
+ VERIFY_IS_APPROX(cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
+ }
m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);
@@ -123,11 +129,18 @@ template<typename Scalar, int Mode, int Options> void transformations()
// 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);
+
+ if(abs(aa.angle()) > NumTraits<Scalar>::dummy_precision())
+ {
+ VERIFY( !(q1 * v1).isApprox(Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1) );
+ }
aa.fromRotationMatrix(aa.toRotationMatrix());
VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
- VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1);
+ if(abs(aa.angle()) > NumTraits<Scalar>::dummy_precision())
+ {
+ VERIFY( !(q1 * v1).isApprox(Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1) );
+ }
// AngleAxis
VERIFY_IS_APPROX(AngleAxisx(a,v1.normalized()).toRotationMatrix(),
@@ -347,7 +360,9 @@ template<typename Scalar, int Mode, int Options> void transformations()
// test transform inversion
t0.setIdentity();
t0.translate(v0);
- t0.linear().setRandom();
+ do {
+ t0.linear().setRandom();
+ } while(t0.linear().jacobiSvd().singularValues()(2)<test_precision<Scalar>());
Matrix4 t044 = Matrix4::Zero();
t044(3,3) = 1;
t044.block(0,0,t0.matrix().rows(),4) = t0.matrix();