public static LFloat Angle(LQuaternion a, LQuaternion b) { LQuaternion q = b * LQuaternion.Inverse(a); q.Normalize(); return(LMath.Acos(q.w)); }
public static LVector3 ToEulerAngles(LQuaternion rotation) { rotation.Normalize(); return(new LVector3( LMath.Atan2(2 * (rotation.w * rotation.z + rotation.x * rotation.y), 1 - 2 * (rotation.z * rotation.z + rotation.x * rotation.x)), LMath.Asin(2 * (rotation.w * rotation.x - rotation.y * rotation.z)), LMath.Atan2(2 * (rotation.w * rotation.y + rotation.z * rotation.x), 1 - 2 * (rotation.x * rotation.x + rotation.y * rotation.y)) )); }