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