예제 #1
0
        /// <summary>
        /// Compute the shortest arc quaternion with a fixed yaw axis.
        /// </summary>
        /// <param name="direction">The direction to face. Must be normalized.</param>
        /// <param name="yawFixedAxis">The axis to fix as yaw.</param>
        /// <returns>The quaternion that will get to this orientation.</returns>
        public static Quaternion shortestArcQuatFixedYaw(ref Vector3 direction, ref Vector3 yawFixedAxis)
        {
            Vector3 xVec = yawFixedAxis.cross(ref direction);

            xVec.normalize();

            Vector3 yVec = direction.cross(ref xVec);

            yVec.normalize();

            Quaternion targetWorldOrientation = new Quaternion();

            targetWorldOrientation.fromAxes(xVec, yVec, direction);

            return(targetWorldOrientation);
        }
예제 #2
0
 /// <summary>
 /// Find the shortest arc, but first normalize the two vectors.
 /// </summary>
 /// <param name="v0">Source vector.</param>
 /// <param name="v1">Destination vector.</param>
 /// <returns>The quaternion with the shortest arc.</returns>
 public static Quaternion shortestArcQuatNormalize2(ref Vector3 v0, ref Vector3 v1)
 {
     v0.normalize();
     v1.normalize();
     return(shortestArcQuat(ref v0, ref v1));
 }