/// <summary>
        /// Transforms a vector by the transposed of the given Matrix.
        /// </summary>
        /// <param name="position">The vector to transform.</param>
        /// <param name="matrix">The transform matrix.</param>
        /// <param name="result">The transformed vector.</param>
        public static void TransposedTransform(ref Fixed64Vector3 position, ref Fixed64Matrix matrix, out Fixed64Vector3 result)
        {
            Fixed64 num0 = ((position.x * matrix.M11) + (position.y * matrix.M12)) + (position.z * matrix.M13);
            Fixed64 num1 = ((position.x * matrix.M21) + (position.y * matrix.M22)) + (position.z * matrix.M23);
            Fixed64 num2 = ((position.x * matrix.M31) + (position.y * matrix.M32)) + (position.z * matrix.M33);

            result.x = num0;
            result.y = num1;
            result.z = num2;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a quaternion from a matrix.
        /// </summary>
        /// <param name="matrix">A matrix representing an orientation.</param>
        /// <param name="result">JQuaternion representing an orientation.</param>
        public static void CreateFromMatrix(ref Fixed64Matrix matrix, out Fixed64Quaternion result)
        {
            Fixed64 num8 = (matrix.M11 + matrix.M22) + matrix.M33;

            if (num8 > Fixed64.Zero)
            {
                Fixed64 num = Fixed64.Sqrt((num8 + Fixed64.One));
                result.w = num * Fixed64.Half;
                num      = Fixed64.Half / num;
                result.x = (matrix.M23 - matrix.M32) * num;
                result.y = (matrix.M31 - matrix.M13) * num;
                result.z = (matrix.M12 - matrix.M21) * num;
            }
            else if ((matrix.M11 >= matrix.M22) && (matrix.M11 >= matrix.M33))
            {
                Fixed64 num7 = Fixed64.Sqrt((((Fixed64.One + matrix.M11) - matrix.M22) - matrix.M33));
                Fixed64 num4 = Fixed64.Half / num7;
                result.x = Fixed64.Half * num7;
                result.y = (matrix.M12 + matrix.M21) * num4;
                result.z = (matrix.M13 + matrix.M31) * num4;
                result.w = (matrix.M23 - matrix.M32) * num4;
            }
            else if (matrix.M22 > matrix.M33)
            {
                Fixed64 num6 = Fixed64.Sqrt((((Fixed64.One + matrix.M22) - matrix.M11) - matrix.M33));
                Fixed64 num3 = Fixed64.Half / num6;
                result.x = (matrix.M21 + matrix.M12) * num3;
                result.y = Fixed64.Half * num6;
                result.z = (matrix.M32 + matrix.M23) * num3;
                result.w = (matrix.M31 - matrix.M13) * num3;
            }
            else
            {
                Fixed64 num5 = Fixed64.Sqrt((((Fixed64.One + matrix.M33) - matrix.M11) - matrix.M22));
                Fixed64 num2 = Fixed64.Half / num5;
                result.x = (matrix.M31 + matrix.M13) * num2;
                result.y = (matrix.M32 + matrix.M23) * num2;
                result.z = Fixed64.Half * num5;
                result.w = (matrix.M12 - matrix.M21) * num2;
            }
        }
 /// <summary>
 /// Transforms a vector by the given matrix.
 /// </summary>
 /// <param name="position">The vector to transform.</param>
 /// <param name="matrix">The transform matrix.</param>
 /// <returns>The transformed vector.</returns>
 public static Fixed64Vector3 Transform(Fixed64Vector3 position, Fixed64Matrix matrix)
 {
     Transform(ref position, ref matrix, out Fixed64Vector3 result);
     return(result);
 }
Beispiel #4
0
 /// <summary>
 /// Creates a quaternion from a matrix.
 /// </summary>
 /// <param name="matrix">A matrix representing an orientation.</param>
 /// <returns>JQuaternion representing an orientation.</returns>
 #region public static JQuaternion CreateFromMatrix(JMatrix matrix)
 public static Fixed64Quaternion CreateFromMatrix(Fixed64Matrix matrix)
 {
     CreateFromMatrix(ref matrix, out Fixed64Quaternion result);
     return(result);
 }
Beispiel #5
0
 public static Fixed64Quaternion LookRotation(Fixed64Vector3 forward, Fixed64Vector3 upwards)
 {
     return(CreateFromMatrix(Fixed64Matrix.LookAt(forward, upwards)));
 }