Angle from Rotation matrix ?

Started by
8 comments, last by clb 12 years, 6 months ago
Hello Good people, Is there anyway to get angle from rotation matrix ? Matrix like this [ xx, yx, zx, px; xy, yy, zy, py; xz, yz, zz, pz; 0, 0, 0, 1 ] Thanks in advance KD If you Dream, You can.
Advertisement
Quote:Original post by kdworld
Hello Good people,

Is there anyway to get angle from rotation matrix ?
Matrix like this
[
xx, yx, zx, px;
xy, yy, zy, py;
xz, yz, zz, pz;
0, 0, 0, 1
]

Thanks in advance
KD
If you Dream, You can.
There isn't really any meaningful way to extract a single angle from a 3-d affine transform matrix (as the above appears to be). However, if the linear portion is a pure rotation, you can extract an Euler-angle triple or an axis-angle pair.
Thank you JYK for the reply.
So consider the case of pure rotation (matrix is 3X3), the how can i get the eular angle from the matrix.

Please reply.
What you're looking for is 'rotation matrix to Euler conversion'.

Google will be one source of information. Keep in mind though that there are different conventions for matrix storage, vector notation, and axis order that will cause most examples to differ from each other.

If you need a code reference, you might check out geometrictools.com - the math library there includes code for Euler-angle conversions using various axis orders (using column-basis matrices, I believe). Also, the math library linked in my signature includes support for Euler-angle conversions using matrices of any storage order and basis orientation, and any axis order (including repeating orders such as XYX).

I'll ask though, why do you need to perform this conversion? (It seems that quite often people seem to think that they 'need' to use Euler angles when they actually don't - and when, in fact, some other representation would be preferable.)
Thanks JYK .

Actually i just need the rotation matrix. But since i am self learner , i tried to find out the Euler angles from the Matrix. I will check out that links. Thanks.
By the way, i myself created some formulas for getting the angle using asin functions. (I just tested it with simple cases)
Following are they.
Z = asin(y coorinate of X axis) * 180/Pi
x = asin(z coorinate of y axis) * 180/Pi
y = asin(y coorinate of z axis) * 180/Pi
Quote:Original post by jyk
(It seems that quite often people seem to think that they 'need' to use Euler angles when they actually don't - and when, in fact, some other representation would be preferable.)


Some times it is necessary. I develop a plugin that emulates one application's content (Poser) in another application (Cinema 4D). All rotations in Poser are Euler (period - XYZ, XZY, YXZ, YZX, ZXY, or ZYX). Things that are slaved to the rotations use the Euler rotation values (in degrees, specifically) to determine their values (not quaternions, matrices, or some other value). So, in order to maintain these relationships between values, the Euler degree representations must be maintained. That and the deformations are done axially (x-axis applies its weights, y-axis applies its weights, z-axis applies its weights each dependent upon the amount of rotation per axis). These would be meaningless if applied using quaternions, just using regular-old skinning techniques, or even using matrix decomposition to get Euler angles (because we all know that you cannot get exact representations back; only equivalents). And it's worse since this involves a 'hierarchy of rotations' (the equivalents would feed down the hierarchy for even more chaos).

Sorry. As long Euler rotations exist, we will be at their mercy (unfortunately). :)

Thanks JYK .

Actually i just need the rotation matrix. But since i am self learner , i tried to find out the Euler angles from the Matrix. I will check out that links. Thanks.
By the way, i myself created some formulas for getting the angle using asin functions. (I just tested it with simple cases)
Following are they.
Z = asin(y coorinate of X axis) * 180/Pi
x = asin(z coorinate of y axis) * 180/Pi
y = asin(y coorinate of z axis) * 180/Pi



I think for y angle it need to be x coordinate of z axis. Is it correct?
because I calculated the rotation matrix as
| cos(xAng).cos(zAng) -sin(zAng) sin(yAng) t[sub]x[/sub] |
| sin(zAng) cos(xAng).cos(zAng) -sin(xAng) t[sub]y[/sub] |
| -sin(yAng) sin(xAng) cos(xAng).cos(yAng) t[sub]x[/sub] |
| s[sub]x[/sub] s[sub]y[/sub] s[sub]z[/sub] s |

Is it correct?

Regards

Abhay

David Eberly's GeometricTools.com page does not let you down here either.

See http://www.geometrictools.com/Documentation/EulerAngles.pdf . It contains a lot of formulations for different ways of breaking down matrices into Euler angles.

Wow nice link.... Thank you...

Wanted to come and ask if I could find the individual matrices when they where combined in this way...

This is only for a 2D game

Matrix Transform =
Matrix.CreateTranslation(new Vector3(-vDrawObject.Origin, 0.0f)) *
Matrix.CreateScale(vDrawObject.Scale.X, vDrawObject.Scale.Y, 1) *
Matrix.CreateRotationZ(vDrawObject.Rotation) *
Matrix.CreateTranslation(new Vector3(vDrawObject.X, vDrawObject.Y, 0.0f));


I guess I will find the answer there :)

Off to read
Your matrix is of form M=T1*S*R*T2. It is not possible to reconstruct the original T1, and T2 matrices given M, but it is possible to reconstruct S and R and a translation matrix T3, so that M=S*R*T3 (or M=T3*S*R, depending on the order you want).

Simply by looking at M we cannot tell between T1 and T2, i.e. what amount of translation was performed before and after the scale and rotation operations.

This topic is closed to new replies.

Advertisement