cargo fmt

This commit is contained in:
Sébastien Crozet 2022-07-27 09:46:02 +02:00
parent 26e69863e1
commit 18a8a30671
1 changed files with 32 additions and 12 deletions

View File

@ -1,5 +1,7 @@
use na::{
Matrix3, Quaternion, RealField, Rotation3, UnitQuaternion, UnitVector3, Vector2, Vector3,
};
use std::f64::consts::PI; use std::f64::consts::PI;
use na::{Matrix3, Quaternion, RealField, Rotation3, UnitQuaternion, UnitVector3, Vector2, Vector3};
#[test] #[test]
fn angle_2() { fn angle_2() {
@ -20,23 +22,41 @@ fn angle_3() {
#[test] #[test]
fn from_rotation_matrix() { fn from_rotation_matrix() {
// Test degenerate case when from_matrix gets stuck in Identity rotation // Test degenerate case when from_matrix gets stuck in Identity rotation
let identity = Rotation3::from_matrix(&Matrix3::new( let identity =
1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0));
));
assert_relative_eq!(identity, &Rotation3::identity(), epsilon = 0.001); assert_relative_eq!(identity, &Rotation3::identity(), epsilon = 0.001);
let rotated_z = Rotation3::from_matrix(&Matrix3::new( let rotated_z =
1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0));
)); assert_relative_eq!(
assert_relative_eq!(rotated_z, &Rotation3::from_axis_angle(&UnitVector3::new_unchecked(Vector3::new(1.0, 0.0, 0.0)), PI), epsilon = 0.001); 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 // Test that issue 628 is fixed
let m_628 = nalgebra::Matrix3::<f64>::new(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); let m_628 = nalgebra::Matrix3::<f64>::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_ne!(
assert_relative_eq!(nalgebra::Rotation3::from_matrix_unchecked(m_628.clone()), nalgebra::Rotation3::from_matrix(&m_628), epsilon = 0.001); 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 // Test that issue 1078 is fixed
let m_1078 = nalgebra::Matrix3::<f64>::new(0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0); let m_1078 = nalgebra::Matrix3::<f64>::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_ne!(
assert_relative_eq!(nalgebra::Rotation3::from_matrix_unchecked(m_1078.clone()), nalgebra::Rotation3::from_matrix(&m_1078), epsilon = 0.001); 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] #[test]