public static float GetRotationAngleViaQuaternionsInDegrees(CoordinateSystem move, CoordinateSystem reference) { float angleRadians = GetRotationAngleViaQuaternionsInRadians(move, reference); float angleDegrees = (float)(angleRadians * 180 / Math.PI); return(angleDegrees); }
public void Copy(CoordinateSystem other) { Transform = other.Transform; }
public CoordinateSystem(CoordinateSystem other) { Transform = other.Transform; }
/// <summary> /// Computes the minimal rotation angle required to align the reference coordinate system to other, ignoring the final translation /// that would be required to merge them. /// </summary> /// <param name="move"></param> /// <param name="reference"></param> /// <returns></returns> public static float GetRotationAngleViaQuaternionsInRadians(CoordinateSystem move, CoordinateSystem reference) { Quaternion referenceInverse = Quaternion.Inverse(reference.Rotation); Quaternion moveRelativeToReference = move.Rotation * referenceInverse; moveRelativeToReference.Normalize(); float angle = (float)Math.Acos(moveRelativeToReference.W) * 2; if (angle > Math.PI) { angle = (float)(angle - 2 * Math.PI); } if (angle < -Math.PI) { angle = (float)(angle + 2 * Math.PI); } Debug.Assert(-Math.PI <= angle && angle <= Math.PI); return(angle); }