use na::{Real, U3, Unit, UnitQuaternion, Vector3}; use aliases::{Vec, Qua}; /// The rotation angle of this quaternion assumed to be normalized. pub fn angle(x: &Qua) -> N { UnitQuaternion::from_quaternion(*x).angle() } /// Creates a quaternion from an axis and an angle. pub fn angle_axis(angle: N, axis: &Vec) -> Qua { UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).unwrap() } /// The rotation axis of a quaternion assumed to be normalized. pub fn axis(x: &Qua) -> Vec { if let Some(a) = UnitQuaternion::from_quaternion(*x).axis() { a.unwrap() } else { Vector3::zeros() } }