Advertisement

Coordinate axis factoring of a rotation matrix

Started by November 20, 2002 10:29 AM
1 comment, last by _walrus 22 years, 2 months ago
Assuming there there is just rotations specfied in a transformation how does one factor it into the product of three coordinate axis rotation Rx*Ry*Rz. I have an algorithm which i believe works but its not quit giving me correct results :

inline    void getFactoredCoordinateAxisRotationDegreesIntoArray(double* theta) {
        //Factor as RxRyRz, assumes that axiss are orthanormal
    
        double thetaY = asin(m31);
        theta[1] = thetaY;
        if (thetaY < PI/2.0f) {
            if (thetaY > -PI/2.0f) {
                theta[0] = atan2(-m32, m33);
                theta[2] = atan2(-m21, m11);
            }
            else {
                theta[0] = -atan2(m12, m22);
                theta[2] = 0.0f; 
            }
        }
        else {
            theta[0] = atan2(m12, m22);
            theta[2] = 0.0f;
        }
    }
thanks
the Factored rotations for matrix
0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
1.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 1.000000

are 0.000000 89.999995 0.000000 about the x y z axis repectively, but as we can see this is not true. I''m not sure why this case is not working for my algorithm. Any ideas as to why this specfic matrix breaks the algorithm
Advertisement
Dave Eberly''s reference should help:

http://www.magic-software.com/Documentation/EulerAngles.pdf

See Section 2 "Factoring Rotation Matrices". Better yet, download his code, MgcMatrix.*, and use his implemented methods ToEulerAnglesXYZ(...), etc.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement