From e741b436684da485a9abd6d46686a0be143296e0 Mon Sep 17 00:00:00 2001 From: Essex Edwards Date: Mon, 14 Dec 2020 13:03:46 -0800 Subject: Make Transform::computeRotationScaling(0,&S) continuous --- test/geo_transformations.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/geo_transformations.cpp') 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 void transformations_no_scale() VERIFY(t3.rotation().data()==t3.linear().data()); } +template void transformations_computed_scaling_continuity() +{ + typedef Matrix Vector3; + typedef Transform Transform3; + typedef Matrix 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() )); CALL_SUBTEST_1(( non_projective_only() )); + CALL_SUBTEST_1(( transformations_computed_scaling_continuity() )); CALL_SUBTEST_2(( transformations() )); CALL_SUBTEST_2(( non_projective_only() )); -- cgit v1.2.3