コード例 #1
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 Fixed64Quaternion Multiply(Fixed64Quaternion quaternion1, Fixed64 scaleFactor)
 {
     Multiply(ref quaternion1, scaleFactor, out Fixed64Quaternion result);
     return(result);
 }
コード例 #2
0
        public static Fixed64Quaternion LerpUnclamped(Fixed64Quaternion a, Fixed64Quaternion b, Fixed64 t)
        {
            Fixed64Quaternion result = Multiply(a, (1 - t)) + Multiply(b, t);

            result.Normalize();

            return(result);
        }
コード例 #3
0
        public static Fixed64Quaternion Lerp(Fixed64Quaternion a, Fixed64Quaternion b, Fixed64 t)
        {
            t = FixedMath.Clamp(t, Fixed64.Zero, Fixed64.One);

            return(LerpUnclamped(a, b, t));
        }
コード例 #4
0
        public static Fixed64Quaternion Inverse(Fixed64Quaternion rotation)
        {
            Fixed64 invNorm = Fixed64.One / ((rotation.x * rotation.x) + (rotation.y * rotation.y) + (rotation.z * rotation.z) + (rotation.w * rotation.w));

            return(Multiply(Conjugate(rotation), invNorm));
        }
コード例 #5
0
        public static Fixed64Quaternion RotateTowards(Fixed64Quaternion from, Fixed64Quaternion to, Fixed64 maxDegreesDelta)
        {
            Fixed64 dot = Dot(from, to);

            if (dot < 0.0f)
            {
                to  = Multiply(to, -1);
                dot = -dot;
            }

            Fixed64 halfTheta = Fixed64.Acos(dot);
            Fixed64 theta     = halfTheta * 2;

            maxDegreesDelta *= Fixed64.Deg2Rad;

            if (maxDegreesDelta >= theta)
            {
                return(to);
            }

            maxDegreesDelta /= theta;

            return(Multiply(Multiply(from, Fixed64.Sin((1 - maxDegreesDelta) * halfTheta)) + Multiply(to, Fixed64.Sin(maxDegreesDelta * halfTheta)), 1 / Fixed64.Sin(halfTheta)));
        }
コード例 #6
0
        public static Fixed64Quaternion Slerp(Fixed64Quaternion from, Fixed64Quaternion to, Fixed64 t)
        {
            t = FixedMath.Clamp(t, 0, 1);

            Fixed64 dot = Dot(from, to);

            if (dot < 0.0f)
            {
                to  = Multiply(to, -1);
                dot = -dot;
            }

            Fixed64 halfTheta = Fixed64.Acos(dot);

            return(Multiply(Multiply(from, Fixed64.Sin((1 - t) * halfTheta)) + Multiply(to, Fixed64.Sin(t * halfTheta)), 1 / Fixed64.Sin(halfTheta)));
        }