Example #1
0
        public static float GetRotationAngleViaQuaternionsInDegrees(CoordinateSystem move, CoordinateSystem reference)
        {
            float angleRadians = GetRotationAngleViaQuaternionsInRadians(move, reference);
            float angleDegrees = (float)(angleRadians * 180 / Math.PI);

            return(angleDegrees);
        }
Example #2
0
 public void Copy(CoordinateSystem other)
 {
     Transform = other.Transform;
 }
Example #3
0
 public CoordinateSystem(CoordinateSystem other)
 {
     Transform = other.Transform;
 }
Example #4
0
        /// <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);
        }