Example #1
0
        // Originally: void QuaternionAngles( const Quaternion &q, RadianEuler &angles )
        // "Purpose: Converts a quaternion into engine angles
        //  Input  : *quaternion - q3 + q0.i + q1.j + q2.k
        //           *outAngles - PITCH, YAW, ROLL"
        public Vector3 ToRadianAngles()
        {
            // FIXME: doing it this way calculates too much data, needs to do an optimized version...
            // I wonder if they ever came up with an optimized version
            VMatrix m = this.ToMatrix();

            return(m.ToRadianAngles());
        }
Example #2
0
        // Originally: void QuaternionMatrix( const Quaternion &q, matrix3x4_t& matrix )
        public VMatrix ToMatrix()
        {
            VMatrix m = VMatrix.Zero;

            m.M00 = 1.0f - 2.0f * Y * Y - 2.0f * Z * Z;
            m.M10 = 2.0f * X * Y + 2.0f * W * Z;
            m.M20 = 2.0f * X * Z - 2.0f * W * Y;

            m.M01 = 2.0f * X * Y - 2.0f * W * Z;
            m.M11 = 1.0f - 2.0f * X * X - 2.0f * Z * Z;
            m.M21 = 2.0f * Y * Z + 2.0f * W * X;

            m.M02 = 2.0f * X * Z + 2.0f * W * Y;
            m.M12 = 2.0f * Y * Z - 2.0f * W * X;
            m.M22 = 1.0f - 2.0f * X * X - 2.0f * Y * Y;

            m.M03 = 0.0f;
            m.M13 = 0.0f;
            m.M23 = 0.0f;

            return(m);
        }