/// Convert a Quaternion to Eular angles
///     This is a polar singularity aware conversion
///
///  Based on:
/// - [Maths - Conversion Quaternion to Euler]
///   (http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/)
Convert a Quaternion to Eular angles
This is a polar singularity aware conversion

Based on:
[Maths - Conversion Quaternion to Euler]
Convert a Quaternion to Eular angles This is a polar singularity aware conversion Based on : [ Maths - Conversion Quaternion to Euler ]
pub fn to_euler(self) -> (Rad<S>, Rad<S>, Rad<S>) {
        let sig: S = cast(0.499f64).unwrap();
        let two: S = cast(2f64).unwrap();
        let one: S = cast(1f64).unwrap();
        let (qw, qx, qy, qz) = (self.s, self.v.x, self.v.y, self.v.z);
        let (sqw, sqx, sqy, sqz) = (qw * qw, qx * qx, qy * qy, qz * qz);
        let unit = sqx + sqy + sqz + sqw;
        let test = qx * qy + qz * qw;
        if test > sig * unit {
            (
                Rad::zero(),
                Rad::turn_div_4(),
                Rad::atan2(qx, qw) * two,
            )
        } else if test < -sig * unit {
            (
                Rad::zero(),
                -Rad::turn_div_4(),
                Rad::atan2(qx, qw) * two,
            )
        } else {
            (
                Rad::atan2(two * (qy * qw - qx * qz), one - two * (sqy + sqz)),
                Rad::asin(two * (qx * qy + qz * qw)),
                Rad::atan2(two * (qx * qw - qy * qz), one - two * (sqx + sqz)),
            )
        }
    }
pub fn to_euler ( self ) -> ( Rad < S > , Rad < S > , Rad < S > ) { let sig : S = cast ( 0.499f64 ) . unwrap ( ) ; let two : S = cast ( 2f64 ) . unwrap ( ) ; let one : S = cast ( 1f64 ) . unwrap ( ) ; let ( qw , qx , qy , qz ) = ( self . s , self . v . x , self . v . y , self . v . z ) ; let ( sqw , sqx , sqy , sqz ) = ( qw * qw , qx * qx , qy * qy , qz * qz ) ; let unit = sqx + sqy + sqz + sqw ; let test = qx * qy + qz * qw ; if test > sig * unit { ( Rad :: zero ( ) , Rad :: turn_div_4 ( ) , Rad :: atan2 ( qx , qw ) * two , ) } else if test < - sig * unit { ( Rad :: zero ( ) , - Rad :: turn_div_4 ( ) , Rad :: atan2 ( qx , qw ) * two , ) } else { ( Rad :: atan2 ( two * ( qy * qw - qx * qz ) , one - two * ( sqy + sqz ) ) , Rad :: asin ( two * ( qx * qy + qz * qw ) ) , Rad :: atan2 ( two * ( qx * qw - qy * qz ) , one - two * ( sqx + sqz ) ) , ) } }
Convert a Quaternion to Eular angles
This is a polar singularity aware conversion
Convert a Quaternion to Eular angles This is a polar singularity aware conversion
self