From 7a43827bb757160068847deba5a86454587b1b08 Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Tue, 29 Mar 2022 11:56:31 -0500 Subject: [PATCH] added docs to slerp and powf for Rotation --- src/geometry/rotation_interpolation.rs | 17 ++++++++++++++++- src/geometry/rotation_specialization.rs | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/geometry/rotation_interpolation.rs b/src/geometry/rotation_interpolation.rs index ff81ab69..7d475dc7 100644 --- a/src/geometry/rotation_interpolation.rs +++ b/src/geometry/rotation_interpolation.rs @@ -89,11 +89,26 @@ impl Rotation where Allocator,U1>> { + /// + /// Computes the spherical linear interpolation between two general rotations. + /// + /// # Examples: + /// + /// ``` + /// # use nalgebra::geometry::Rotation3; + /// + /// 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 q = q1.slerp(&q2, 1.0 / 3.0); + /// + /// assert_eq!(q.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0)); + /// ``` + /// //FIXME: merging slerp for Rotation2 and Rotation3 into this raises the trait bounds //from SimdRealField to RealField #[inline] #[must_use] - #[warn(missing_docs)] pub fn slerp(&self, other: &Self, t:T) -> Self { use std::mem::transmute; diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index d3104c36..40fe5b12 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -1010,8 +1010,24 @@ where impl Rotation { + /// + /// Raise the rotation to a given floating power, i.e., returns the rotation with the same + /// axis as `self` and an angle equal to `self.angle()` multiplied by `n`. + /// + /// # Example + /// ``` + /// # #[macro_use] extern crate approx; + /// # use nalgebra::{Rotation3, Vector3, Unit}; + /// + /// let axis = Unit::new_normalize(Vector3::new(1.0, 2.0, 3.0)); + /// let angle = 1.2; + /// let rot = Rotation3::from_axis_angle(&axis, angle); + /// let pow = rot.powf(2.0); + /// + /// assert_relative_eq!(pow.axis().unwrap(), axis, epsilon = 1.0e-6); + /// assert_eq!(pow.angle(), 2.4); + /// ``` //FIXME: merging powf for Rotation2 into this raises the trait bounds from SimdRealField to RealField - #[warn(missing_docs)] pub fn powf(&self, t: T) -> Self where Const: DimSub, ArrayStorage: Storage,Const>,