Example #1
0
        /// <summary>
        /// Multiply two quaternions.
        /// </summary>
        /// <param name="value1">The first quaternion.</param>
        /// <param name="value2">The second quaternion.</param>
        /// <returns>The product of both quaternions.</returns>
        #region public static FP operator *(JQuaternion value1, JQuaternion value2)
        public static FPQuaternion operator *(FPQuaternion value1, FPQuaternion value2)
        {
            FPQuaternion result;

            FPQuaternion.Multiply(ref value1, ref value2, out result);
            return(result);
        }
Example #2
0
        /// <summary>
        /// Scale a quaternion
        /// </summary>
        /// <param name="quaternion1">The quaternion to scale.</param>
        /// <param name="scaleFactor">Scale factor.</param>
        /// <returns>The scaled quaternion.</returns>
        #region public static JQuaternion Multiply(JQuaternion quaternion1, FP scaleFactor)
        public static FPQuaternion Multiply(FPQuaternion quaternion1, FP scaleFactor)
        {
            FPQuaternion result;

            FPQuaternion.Multiply(ref quaternion1, scaleFactor, out result);
            return(result);
        }
Example #3
0
        /// <summary>
        /// Multiply two quaternions.
        /// </summary>
        /// <param name="quaternion1">The first quaternion.</param>
        /// <param name="quaternion2">The second quaternion.</param>
        /// <returns>The product of both quaternions.</returns>
        #region public static JQuaternion Multiply(JQuaternion quaternion1, JQuaternion quaternion2)
        public static FPQuaternion Multiply(FPQuaternion quaternion1, FPQuaternion quaternion2)
        {
            FPQuaternion result;

            FPQuaternion.Multiply(ref quaternion1, ref quaternion2, out result);
            return(result);
        }
Example #4
0
        public static FPQuaternion LerpUnclamped(FPQuaternion a, FPQuaternion b, FP t)
        {
            FPQuaternion result = FPQuaternion.Multiply(a, (1 - t)) + FPQuaternion.Multiply(b, t);

            result.Normalize();

            return(result);
        }
        public static FPQuaternion LerpUnclamped(FPQuaternion a, FPQuaternion b, FP t)
        {
            FPQuaternion tmpQuat;

            // if (dot < 0), q1 and q2 are more than 360 deg apart.
            // The problem is that quaternions are 720deg of freedom.
            // so we - all components when lerping
            if (Dot(a, b) < 0.0F)
            {
                tmpQuat = FPQuaternion.Multiply(b, -1);
            }
            else
            {
                tmpQuat = b;
            }

            FPQuaternion result = FPQuaternion.Multiply(a, (1 - t)) + FPQuaternion.Multiply(tmpQuat, t);

            result.Normalize();

            return(result);
        }
Example #6
0
        public static FPQuaternion Inverse(FPQuaternion rotation)
        {
            FP invNorm = FP.One / ((rotation.x * rotation.x) + (rotation.y * rotation.y) + (rotation.z * rotation.z) + (rotation.w * rotation.w));

            return(FPQuaternion.Multiply(FPQuaternion.Conjugate(rotation), invNorm));
        }