From c410a32c8279d2d3b10c654a893d431025d6135c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Sun, 25 Oct 2020 14:15:26 +0100 Subject: [PATCH] Fix doc-tests. --- src/geometry/isometry.rs | 58 +++++++++++++------------ src/geometry/rotation_specialization.rs | 3 +- src/geometry/unit_complex.rs | 3 +- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index c8eb34fb..edb27b5a 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -387,10 +387,10 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector3, Translation3, UnitQuaternion}; + /// # use nalgebra::{Vector3, Translation3, Isometry3, UnitQuaternion}; /// /// let t1 = Translation3::new(1.0, 2.0, 3.0); - /// let t2 = Translation3::new(3.0, 6.0, 9.0); + /// let t2 = Translation3::new(4.0, 8.0, 12.0); /// let q1 = UnitQuaternion::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0); /// let q2 = UnitQuaternion::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0); /// let iso1 = Isometry3::from_parts(t1, q1); @@ -398,7 +398,7 @@ impl Isometry> { /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector3::new(2.0, 4.0, 6.0)); + /// assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0)); /// assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0)); /// ``` #[inline] @@ -420,10 +420,10 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector3, Translation3, UnitQuaternion}; + /// # use nalgebra::{Vector3, Translation3, Isometry3, UnitQuaternion}; /// /// let t1 = Translation3::new(1.0, 2.0, 3.0); - /// let t2 = Translation3::new(3.0, 6.0, 9.0); + /// let t2 = Translation3::new(4.0, 8.0, 12.0); /// let q1 = UnitQuaternion::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0); /// let q2 = UnitQuaternion::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0); /// let iso1 = Isometry3::from_parts(t1, q1); @@ -431,7 +431,7 @@ impl Isometry> { /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector3::new(2.0, 4.0, 6.0)); + /// assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0)); /// assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0)); /// ``` #[inline] @@ -455,18 +455,18 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector3, Translation3, Rotation3}; + /// # use nalgebra::{Vector3, Translation3, Rotation3, IsometryMatrix3}; /// /// let t1 = Translation3::new(1.0, 2.0, 3.0); - /// let t2 = Translation3::new(3.0, 6.0, 9.0); + /// let t2 = Translation3::new(4.0, 8.0, 12.0); /// let q1 = Rotation3::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0); /// let q2 = Rotation3::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0); - /// let iso1 = Isometry3::from_parts(t1, q1); - /// let iso2 = Isometry3::from_parts(t2, q2); + /// let iso1 = IsometryMatrix3::from_parts(t1, q1); + /// let iso2 = IsometryMatrix3::from_parts(t2, q2); /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector3::new(2.0, 4.0, 6.0)); + /// assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0)); /// assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0)); /// ``` #[inline] @@ -488,18 +488,18 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector3, Translation3, Rotation3}; + /// # use nalgebra::{Vector3, Translation3, Rotation3, IsometryMatrix3}; /// /// let t1 = Translation3::new(1.0, 2.0, 3.0); - /// let t2 = Translation3::new(3.0, 6.0, 9.0); + /// let t2 = Translation3::new(4.0, 8.0, 12.0); /// let q1 = Rotation3::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0); /// let q2 = Rotation3::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0); - /// let iso1 = Isometry3::from_parts(t1, q1); - /// let iso2 = Isometry3::from_parts(t2, q2); + /// let iso1 = IsometryMatrix3::from_parts(t1, q1); + /// let iso2 = IsometryMatrix3::from_parts(t2, q2); /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector3::new(2.0, 4.0, 6.0)); + /// assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0)); /// assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0)); /// ``` #[inline] @@ -523,10 +523,11 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector2, Translation2, UnitComplex, Isometry2}; + /// # #[macro_use] extern crate approx; + /// # use nalgebra::{Vector2, Translation2, UnitComplex, Isometry2}; /// /// let t1 = Translation2::new(1.0, 2.0); - /// let t2 = Translation2::new(3.0, 6.0); + /// let t2 = Translation2::new(4.0, 8.0); /// let q1 = UnitComplex::new(std::f32::consts::FRAC_PI_4); /// let q2 = UnitComplex::new(-std::f32::consts::PI); /// let iso1 = Isometry2::from_parts(t1, q1); @@ -534,11 +535,11 @@ impl Isometry> { /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector2::new(2.0, 4.0)); - /// assert_eq!(iso3.rotation.angle(), std::f32::consts::FRAC_PI_2); + /// assert_eq!(iso3.translation.vector, Vector2::new(2.0, 4.0)); + /// assert_relative_eq!(iso3.rotation.angle(), std::f32::consts::FRAC_PI_2); /// ``` #[inline] - pub fn slerp(&self, other: &Self, t: N) -> Self + pub fn lerp_slerp(&self, other: &Self, t: N) -> Self where N: RealField, { @@ -558,22 +559,23 @@ impl Isometry> { /// # Examples: /// /// ``` - /// # use nalgebra::geometry::{Vector2, Translation2, Rotation2, Isometry2}; + /// # #[macro_use] extern crate approx; + /// # use nalgebra::{Vector2, Translation2, Rotation2, IsometryMatrix2}; /// /// let t1 = Translation2::new(1.0, 2.0); - /// let t2 = Translation2::new(3.0, 6.0); + /// let t2 = Translation2::new(4.0, 8.0); /// let q1 = Rotation2::new(std::f32::consts::FRAC_PI_4); /// let q2 = Rotation2::new(-std::f32::consts::PI); - /// let iso1 = Isometry2::from_parts(t1, q1); - /// let iso2 = Isometry2::from_parts(t2, q2); + /// let iso1 = IsometryMatrix2::from_parts(t1, q1); + /// let iso2 = IsometryMatrix2::from_parts(t2, q2); /// /// let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0); /// - /// assert_eq!(iso3.translation_vector, Vector2::new(2.0, 4.0)); - /// assert_eq!(iso3.rotation.angle(), std::f32::consts::FRAC_PI_2); + /// assert_eq!(iso3.translation.vector, Vector2::new(2.0, 4.0)); + /// assert_relative_eq!(iso3.rotation.angle(), std::f32::consts::FRAC_PI_2); /// ``` #[inline] - pub fn slerp(&self, other: &Self, t: N) -> Self + pub fn lerp_slerp(&self, other: &Self, t: N) -> Self where N: RealField, { diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index 7f140c8b..085cb2d8 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -242,6 +242,7 @@ impl Rotation2 { /// # Examples: /// /// ``` + /// # #[macro_use] extern crate approx; /// # use nalgebra::geometry::Rotation2; /// /// let rot1 = Rotation2::new(std::f32::consts::FRAC_PI_4); @@ -249,7 +250,7 @@ impl Rotation2 { /// /// let rot = rot1.slerp(&rot2, 1.0 / 3.0); /// - /// assert_eq!(rot.angle(), std::f32::consts::FRAC_PI_2); + /// assert_relative_eq!(rot.angle(), std::f32::consts::FRAC_PI_2); /// ``` #[inline] pub fn slerp(&self, other: &Self, t: N) -> Self diff --git a/src/geometry/unit_complex.rs b/src/geometry/unit_complex.rs index f6a4f619..a31f3ddf 100755 --- a/src/geometry/unit_complex.rs +++ b/src/geometry/unit_complex.rs @@ -382,6 +382,7 @@ where /// # Examples: /// /// ``` + /// # #[macro_use] extern crate approx; /// # use nalgebra::geometry::UnitComplex; /// /// let rot1 = UnitComplex::new(std::f32::consts::FRAC_PI_4); @@ -389,7 +390,7 @@ where /// /// let rot = rot1.slerp(&rot2, 1.0 / 3.0); /// - /// assert_eq!(rot.angle(), std::f32::consts::FRAC_PI_2); + /// assert_relative_eq!(rot.angle(), std::f32::consts::FRAC_PI_2); /// ``` #[inline]