From ac203fe4fd101e3ae0e0a542f175fcb23f7dabbe Mon Sep 17 00:00:00 2001 From: Tim Taubner Date: Thu, 31 Mar 2022 18:07:04 +0200 Subject: [PATCH] Add test case for issue 628 --- tests/geometry/rotation.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/geometry/rotation.rs b/tests/geometry/rotation.rs index 369b5454..661430a0 100644 --- a/tests/geometry/rotation.rs +++ b/tests/geometry/rotation.rs @@ -19,7 +19,7 @@ fn angle_3() { #[test] fn from_rotation_matrix() { - // Test degenerate case when from_matrix_eps gets stuck in maximum + // Test degenerate case when from_matrix gets stuck in Identity rotation let identity = Rotation3::from_matrix(&Matrix3::new( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, )); @@ -28,10 +28,15 @@ fn from_rotation_matrix() { 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, )); assert_relative_eq!(rotated_z, &Rotation3::from_axis_angle(&UnitVector3::new_unchecked(Vector3::new(1.0, 0.0, 0.0)), PI), epsilon = 0.001); + // Test that issue 628 is fixed + let m_628 = nalgebra::Matrix3::::new(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); + assert_relative_ne!(identity, nalgebra::Rotation3::from_matrix(&m_628), epsilon = 0.01); + assert_relative_eq!(nalgebra::Rotation3::from_matrix_unchecked(m_628.clone()), nalgebra::Rotation3::from_matrix(&m_628), epsilon = 0.001); + // Test that issue 1078 is fixed - let m = nalgebra::Matrix3::::new(0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0); - assert_relative_ne!(identity, nalgebra::Rotation3::from_matrix(&m)); - assert_relative_eq!(nalgebra::Rotation3::from_matrix_unchecked(m.clone()), nalgebra::Rotation3::from_matrix(&m)); + let m_1078 = nalgebra::Matrix3::::new(0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0); + assert_relative_ne!(identity, nalgebra::Rotation3::from_matrix(&m_1078), epsilon = 0.01); + assert_relative_eq!(nalgebra::Rotation3::from_matrix_unchecked(m_1078.clone()), nalgebra::Rotation3::from_matrix(&m_1078), epsilon = 0.001); } #[test]