setAxisAngleFromQuaternion method
Implementation
Vector4 setAxisAngleFromQuaternion(Quaternion q) {
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
// q is assumed to be normalized
w = 2 * math.acos(q.w);
final s = math.sqrt(1 - q.w * q.w);
if (s < 0.0001) {
x = 1;
y = 0;
z = 0;
} else {
x = q.x / s;
y = q.y / s;
z = q.z / s;
}
return this;
}