Function quaternion_core::to_axis_angle
source · pub fn to_axis_angle<T>(q: Quaternion<T>) -> (Vector3<T>, T)where
T: Float,Expand description
Calculate the rotation axis (unit vector) and the rotation angle[rad]
around the axis from the Versor.
If identity quaternion is entered, angle returns zero and
the axis returns a zero vector.
Range of angle: (-π, π]
Examples
let axis_ori = [0.0, 1.0, 2.0];
let angle_ori = PI / 2.0;
let q = from_axis_angle(axis_ori, angle_ori);
let (axis, angle) = to_axis_angle(q);
assert!( (axis_ori[0] - axis[0]).abs() < 1e-12 );
assert!( (axis_ori[0] - axis[0]).abs() < 1e-12 );
assert!( (axis_ori[0] - axis[0]).abs() < 1e-12 );
assert!( (angle_ori - angle).abs() < 1e-12 );