Returns the rotation of a quaternion as x, y, z, theta: a unit axis and the angle in radians, in float64. The identity (no rotation) gives the axis (1, 0, 0) and angle 0. The quaternion should be unit length; for a quaternion with negative w the angle is above pi (the rotation the other way round).
q: Quaternion;
set_from_axis_and_angle(*q, xyz(0, 1, 0), 1.0);
x, y, z, theta := get_axis_and_angle(q);
assert(abs(y - 1) < 0.0001 && abs(x) < 0.0001 && abs(z) < 0.0001 && abs(theta - 1) < 0.0001);get_axis_and_angle :: (
q: Quaternion
) -> (x: float64, y: float64, z: float64, theta: float64)
Returns the unit axis and the angle in radians of the rotation. A quaternion with no rotation part gives the axis (1, 0, 0) and angle 0.
Parameters
- q: Quaternion
- the rotation to read.
Returns
- x: float64
- y: float64
- z: float64
- theta: float64