Exemplo n.º 1
0
        public static JMatrix CreateFromYawPitchRoll(Fix64 yaw, Fix64 pitch, Fix64 roll)
        {
            JMatrix     matrix;
            JQuaternion quaternion;

            JQuaternion.CreateFromYawPitchRoll(yaw, pitch, roll, out quaternion);
            CreateFromQuaternion(ref quaternion, out matrix);
            return(matrix);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a JMatrix representing an orientation from a quaternion.
        /// </summary>
        /// <param name="quaternion">The quaternion the matrix should be created from.</param>
        /// <param name="result">JMatrix representing an orientation.</param>
        public static void CreateFromQuaternion(ref JQuaternion quaternion, out JMatrix result)
        {
            Fix64 num9 = quaternion.X * quaternion.X;
            Fix64 num8 = quaternion.Y * quaternion.Y;
            Fix64 num7 = quaternion.Z * quaternion.Z;
            Fix64 num6 = quaternion.X * quaternion.Y;
            Fix64 num5 = quaternion.Z * quaternion.W;
            Fix64 num4 = quaternion.Z * quaternion.X;
            Fix64 num3 = quaternion.Y * quaternion.W;
            Fix64 num2 = quaternion.Y * quaternion.Z;
            Fix64 num  = quaternion.X * quaternion.W;

            result.M11 = 1f - (2f * (num8 + num7));
            result.M12 = 2f * (num6 + num5);
            result.M13 = 2f * (num4 - num3);
            result.M21 = 2f * (num6 - num5);
            result.M22 = 1f - (2f * (num7 + num9));
            result.M23 = 2f * (num2 + num);
            result.M31 = 2f * (num4 + num3);
            result.M32 = 2f * (num2 - num);
            result.M33 = 1f - (2f * (num8 + num9));
        }