/// Spherical Linear Interpolation
///
/// Return the spherical linear interpolation between the quaternion and
/// `other`. Both quaternions should be normalized first.
///
/// # Performance notes
///
/// The `acos` operation used in `slerp` is an expensive operation, so
/// unless your quaternions are far away from each other it's generally
/// more advisable to use `nlerp` when you know your rotations are going
/// to be small.
///
/// - [Understanding Slerp, Then Not Using It]
///   (http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/)
/// - [Arcsynthesis OpenGL tutorial]
///   (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html)
Spherical Linear Interpolation
Return the spherical linear interpolation between the quaternion and
`other`. Both quaternions should be normalized first.
Spherical Linear Interpolation Return the spherical linear interpolation between the quaternion and ` other ` . Both quaternions should be normalized first .
pub fn slerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S> {
        let dot = self.dot(other);
        let dot_threshold = cast(0.9995f64).unwrap();
        // if quaternions are close together use `nlerp`
        if dot > dot_threshold {
            self.nlerp(other, amount)
        } else {
            // stay within the domain of acos()
            // TODO REMOVE WHEN https://github.com/mozilla/rust/issues/12068 IS RESOLVED
            let robust_dot = if dot > S::one() {
                S::one()
            } else if dot < -S::one() {
                -S::one()
            } else {
                dot
            };
            let theta = Rad::acos(robust_dot.clone());
            let scale1 = Rad::sin(theta * (S::one() - amount));
            let scale2 = Rad::sin(theta * amount);
            (self * scale1 + other * scale2) * Rad::sin(theta).recip()
        }
    }
pub fn slerp ( self , other : Quaternion < S > , amount : S ) -> Quaternion < S > { let dot = self . dot ( other ) ; let dot_threshold = cast ( 0.9995f64 ) . unwrap ( ) ; // if quaternions are close together use `nlerp` if dot > dot_threshold { self . nlerp ( other , amount ) } else { // stay within the domain of acos() // TODO REMOVE WHEN https://github.com/mozilla/rust/issues/12068 IS RESOLVED let robust_dot = if dot > S :: one ( ) { S :: one ( ) } else if dot < - S :: one ( ) { - S :: one ( ) } else { dot } ; let theta = Rad :: acos ( robust_dot . clone ( ) ) ; let scale1 = Rad :: sin ( theta * ( S :: one ( ) - amount ) ) ; let scale2 = Rad :: sin ( theta * amount ) ; ( self * scale1 + other * scale2 ) * Rad :: sin ( theta ) . recip ( ) } }
Spherical Linear Interpolation
Return the spherical linear interpolation between the quaternion and
`other`.
Spherical Linear Interpolation Return the spherical linear interpolation between the quaternion and ` other ` .
self
other
Quaternion<S>
amount
S
performance notes
The `acos` operation used in `slerp` is an expensive operation, so
unless your quaternions are far away from each other it's generally
more advisable to use `nlerp` when you know your rotations are going
to be small.

[Understanding Slerp, Then Not Using It]

[Arcsynthesis OpenGL tutorial]
The ` acos ` operation used in ` slerp ` is an expensive operation so unless your quaternions are far away from each other it ' s generally more advisable to use ` nlerp ` when you know your rotations are going to be small . [ Understanding Slerp Then Not Using It ] [ Arcsynthesis OpenGL tutorial ]