Exemplo n.º 1
0
        public SourceQAngle ToQAngle()
        {
            SourceQAngle anglesOut = new SourceQAngle();

            MathUtils.QuaternionAngles(this, ref anglesOut);
            return(anglesOut);
        }
        public SourceQAngle ToQAngle()
        {
            SourceQAngle angles = new SourceQAngle();

            MathUtils.QuaternionAngles(m_orientation, ref angles);
            return(angles);
        }
Exemplo n.º 3
0
        public static void MatrixQuaternion(SourceMatrix3x4 mat, ref SourceQuaternion q)
        {
            SourceQAngle angles = new SourceQAngle();

            MatrixAngles(mat, ref angles);
            AngleQuaternion(angles, ref q);
        }
Exemplo n.º 4
0
        public static SourceMatrix3x4 AngleMatrix(SourceQAngle angles)
        {
            //float sr, sp, sy, cr, cp, cy;

            //SinCos(DEG2RAD(angles[YAW]), &sy, &cy);
            //SinCos(DEG2RAD(angles[PITCH]), &sp, &cp);
            //SinCos(DEG2RAD(angles[ROLL]), &sr, &cr);

            //SourceMatrix3x4 matrix;
            //// matrix = (YAW * PITCH) * ROLL
            //matrix[0][0] = cp * cy;
            //matrix[1][0] = cp * sy;
            //matrix[2][0] = -sp;

            //// NOTE: Do not optimize this to reduce multiplies! optimizer bug will screw this up.
            //matrix[0][1] = sr * sp * cy + cr * -sy;
            //matrix[1][1] = sr * sp * sy + cr * cy;
            //matrix[2][1] = sr * cp;
            //matrix[0][2] = (cr * sp * cy + -sr * -sy);
            //matrix[1][2] = (cr * sp * sy + -sr * cy);
            //matrix[2][2] = cr * cp;

            //matrix[0][3] = 0.0f;
            //matrix[1][3] = 0.0f;
            //matrix[2][3] = 0.0f;

            //return matrix;
            throw new NotImplementedException();
        }
Exemplo n.º 5
0
        public static void AngleMatrix(SourceQAngle angles, ref SourceMatrix3x4 matrix)
        {
            float sr, sp, sy, cr, cp, cy;

            SinCos(DEG2RAD(angles[1]), out sy, out cy);
            SinCos(DEG2RAD(angles[0]), out sp, out cp);
            SinCos(DEG2RAD(angles[2]), out sr, out cr);

            // matrix = (YAW * PITCH) * ROLL
            matrix[0][0] = cp * cy;
            matrix[1][0] = cp * sy;
            matrix[2][0] = -sp;

            // NOTE: Do not optimize this to reduce multiplies! optimizer bug will screw this up.
            matrix[0][1] = sr * sp * cy + cr * -sy;
            matrix[1][1] = sr * sp * sy + cr * cy;
            matrix[2][1] = sr * cp;
            matrix[0][2] = (cr * sp * cy + -sr * -sy);
            matrix[1][2] = (cr * sp * sy + -sr * cy);
            matrix[2][2] = cr * cp;

            matrix[0][3] = 0.0f;
            matrix[1][3] = 0.0f;
            matrix[2][3] = 0.0f;
        }
Exemplo n.º 6
0
        public static void QuaternionAngles(SourceQuaternion q, ref SourceQAngle angles)
        {
            // FIXME: doing it this way calculates too much data, needs to do an optimized version...
            SourceMatrix3x4 matrix = new SourceMatrix3x4();

            QuaternionMatrix(q, ref matrix);
            MatrixAngles(matrix, ref angles);
        }
Exemplo n.º 7
0
        public static void AngleQuaternion(SourceQAngle angles, ref SourceQuaternion outQuat)
        {
            float sr, sp, sy, cr, cp, cy;

            SinCos(DEG2RAD(angles.y) * 0.5f, out sy, out cy);
            SinCos(DEG2RAD(angles.x) * 0.5f, out sp, out cp);
            SinCos(DEG2RAD(angles.z) * 0.5f, out sr, out cr);

            // NJS: for some reason VC6 wasn't recognizing the common subexpressions:
            float srXcp = sr * cp, crXsp = cr * sp;

            outQuat.x = srXcp * cy - crXsp * sy; // X
            outQuat.y = crXsp * cy + srXcp * sy; // Y

            float crXcp = cr * cp, srXsp = sr * sp;

            outQuat.z = crXcp * sy - srXsp * cy; // Z
            outQuat.w = crXcp * cy + srXsp * sy; // W (real component)
        }
 public SourceRadianEuler(SourceQAngle angles)
 {
     Init(angles.z * 3.14159265358979323846f / 180.0f,
          angles.x * 3.14159265358979323846f / 180.0f,
          angles.y * 3.14159265358979323846f / 180.0f);
 }
 public void SetAngles(SourceQAngle vAngles)
 {
     MathUtils.AngleQuaternion(vAngles, ref m_orientation);
 }
 // for API compatibility with matrix3x4_t
 public void InitFromQAngles(SourceQAngle angles, SourceVector vPosition)
 {
     MathUtils.AngleQuaternion(angles, ref m_orientation);
     m_vPosition = vPosition;
 }
 public SourceCTransform(SourceVector v, SourceQAngle a)
 {
     m_vPosition = v;
     MathUtils.AngleQuaternion(a, ref m_orientation);
 }
Exemplo n.º 12
0
 public static void MatrixAngles(SourceMatrix3x4 matrix, ref SourceQAngle angles)
 {
     //MatrixAngles(matrix, out angles.x);
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
        public static void AngleMatrix(SourceRadianEuler angles, ref SourceMatrix3x4 matrix)
        {
            SourceQAngle quakeEuler = new SourceQAngle(RAD2DEG(angles.y), RAD2DEG(angles.z), RAD2DEG(angles.x));

            AngleMatrix(quakeEuler, ref matrix);
        }
Exemplo n.º 14
0
 public static void AngleMatrix(SourceQAngle angles, SourceVector position, ref SourceMatrix3x4 matrix)
 {
     AngleMatrix(angles, ref matrix);
     MatrixSetColumn(position, 3, ref matrix);
 }
 public SourceDegreeEuler(SourceQAngle angles)
 {
     Init(angles.z, angles.x, angles.y);
 }