Extracting rotation angles from 4x4 Matrixes

Started by
1 comment, last by Mort 21 years, 4 months ago
Is there any way to extract the X, Y and Z rotation angles from a 4x4 matrix, once the matrix has been concentrated from each of the X, Y and Z rotation matrixes ? I was thinking that creating an inverse matrix for each of the X, Y and Z elements might be possible, but I have yet to understand how inverse matrixes work or if it is possible to use one for the solution to my problem. The reason I need calculate the angles, instead of just store the angles used to create the matrix in the first place, is that I just implemented a LookAt() function into my code. The LookAt() function applies a concentrated rotation matrix - Which means I don''t know the angles used for this calculation. Thanks in advance. - Mort
- Mort
Advertisement
Yes there is a way but it''s quite some work.

First, you expand your rotation matrix in their maths forms (in sin,cos from a maths book) in the particular euler order you want ( on paper ).

If you expand the sin,cos correctly, you should see some terms cancel each other off. You can use asin, atan2 to obtain the 3 angles.
A 4x4 3d rotation matrix? Are you using it to make rigid rotation for projective vectors?

In that case the last row and column are simply null-vectors with R44=1 and a 3x3 rotation matrix is the first 3x3 submatrix.

Then the angles could be extracted but with a lot of ambiguity. First of all they''ll be only accurate up to a Pi and even then, one you recover the Y and Z angles you will have to choose between several solutions for X as it becomes a non-linear problem (I think when I did it I had 2 roots).

I am not sure this is what your problem is but I hope this helps.
I use quaternion matrices as it is much easier and faster to extract angles from them.

EPHERE
----------------------- }EPHERE{-----------------------

This topic is closed to new replies.

Advertisement