aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/geo_transformations.cpp
diff options
context:
space:
mode:
authorGravatar Essex Edwards <essexe@zivadynamics.com>2020-12-14 13:03:46 -0800
committerGravatar Antonio Sánchez <cantonios@google.com>2021-01-07 17:45:14 +0000
commite741b436684da485a9abd6d46686a0be143296e0 (patch)
tree7ffb80f31b69bb89126872088cb75e361e8b0ef9 /test/geo_transformations.cpp
parent0bdc0dba2058acea3af4624cf6419c49feacf554 (diff)
Make Transform::computeRotationScaling(0,&S) continuous
Diffstat (limited to 'test/geo_transformations.cpp')
-rw-r--r--test/geo_transformations.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp
index c72267955..d433561cb 100644
--- a/test/geo_transformations.cpp
+++ b/test/geo_transformations.cpp
@@ -672,11 +672,39 @@ template<typename Scalar, int Mode, int Options> void transformations_no_scale()
VERIFY(t3.rotation().data()==t3.linear().data());
}
+template<typename Scalar, int Mode, int Options> void transformations_computed_scaling_continuity()
+{
+ typedef Matrix<Scalar, 3, 1> Vector3;
+ typedef Transform<Scalar, 3, Mode, Options> Transform3;
+ typedef Matrix<Scalar, 3, 3> Matrix3;
+
+ // Given: two transforms that differ by '2*eps'.
+ Scalar eps(1e-3);
+ Vector3 v0 = Vector3::Random().normalized(),
+ v1 = Vector3::Random().normalized(),
+ v3 = Vector3::Random().normalized();
+ Transform3 t0, t1;
+ // The interesting case is when their determinants have different signs.
+ Matrix3 rank2 = 50 * v0 * v0.adjoint() + 20 * v1 * v1.adjoint();
+ t0.linear() = rank2 + eps * v3 * v3.adjoint();
+ t1.linear() = rank2 - eps * v3 * v3.adjoint();
+
+ // When: computing the rotation-scaling parts
+ Matrix3 r0, s0, r1, s1;
+ t0.computeRotationScaling(&r0, &s0);
+ t1.computeRotationScaling(&r1, &s1);
+
+ // Then: the scaling parts should differ by no more than '2*eps'.
+ const Scalar c(2.1); // 2 + room for rounding errors
+ VERIFY((s0 - s1).norm() < c * eps);
+}
+
EIGEN_DECLARE_TEST(geo_transformations)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(( transformations<double,Affine,AutoAlign>() ));
CALL_SUBTEST_1(( non_projective_only<double,Affine,AutoAlign>() ));
+ CALL_SUBTEST_1(( transformations_computed_scaling_continuity<double,Affine,AutoAlign>() ));
CALL_SUBTEST_2(( transformations<float,AffineCompact,AutoAlign>() ));
CALL_SUBTEST_2(( non_projective_only<float,AffineCompact,AutoAlign>() ));