0

I have a 3d object which is free to rotate along x,y and z axis and it is then saved as a transform matrix. In a case where the sequence of rotation is not known and the object is rotated for more than 3 times (eg :-if i rotate the object x-60degress, y-30 degrees, z-45 degrees then again x->30 degrees), is it possible to extract the angles rotated from the transform matrix?.I know that it is possible to get angles if the sequence of rotation is known, but if I have only the final transform matrix with me and nothing else, is it possible to get the angles rotated(x,y,and z) from the transform matrix ?

Vinod Paul
  • 359
  • 2
  • 14
  • Yes it is possible. You can find the help at http://programming-technique.blogspot.com/2012/03/3d-rotation-algorithm-about-arbitrary.html –  Jan 18 '13 at 09:27
  • But it does not show how to get the angle. I need to all three angles – Vinod Paul Jan 18 '13 at 09:38
  • what do you mean it can be rotated in any order? Normally changing the order of rotation changes the result... Do you need it to be in xyz notation or can it be angle and direction? – Hammer Jan 18 '13 at 16:13
  • also are you using a specific library for matrix math already? OpenCV for instance already has a function to do this for you. – Hammer Jan 18 '13 at 16:16
  • By order i meant, for example the if user rotates the 3D object 45 deg along x axis then 45 along y and at last 60 along z axis and in that case the order is known and it is x->y->z. The angle can be retrieved back from the transform matrix for the above matrix. But my case is different the order of rotation is not known 'a priori', and it is the user's wish in which direction it should be rotated. And for different order the output matrix changes(the final transformed matrix). My Qn is, is it possible to retrieve the angle rotated from the matrix for such a condition – Vinod Paul Jan 21 '13 at 05:14
  • The question in its self is not bad, but the way you phrase it in the body is. Stackverflow is not about questions but good answers. So you should wrojk the question out so that it fits better with what your asking. Comment threads dont count. Try to fix teh question so it makes sense to people. – joojaa Jan 22 '13 at 08:18

1 Answers1

2

Euler angle conversion is a pretty well known topic. Just normalize the matrix orientation vectors and then use something like this c source code.

The matrix is the current state of things it has no knowledge of what the transformation has been in the past. It does not know how the matrix was built. You can just take the matrix into and decompose it into any pieces you like, as long as:

  1. The data do not overlap. For example:Two X turns after each other is indistinguishable form each other (no way to know if its 1 2 or three different rotations summed).
  2. The sequence order is known
  3. A decomposition can be built out of the data (for example scale can be measured)
joojaa
  • 4,354
  • 1
  • 27
  • 45
  • please note: x->y->x->z->y is not retrievable. – joojaa Jan 20 '13 at 09:39
  • For that case the order of rotation should be known isn't it?. My case is different, the order of rotation is not known, I mean its not within my hands. The user can rotate the 3D object in what ever order he needs and i just have the final transform matrix with me and nothing else. – Vinod Paul Jan 21 '13 at 05:24
  • And also in my case the steps are not limited to 3(as x->y->z) but it can be x->y->z->y->z->..... – Vinod Paul Jan 21 '13 at 06:01
  • 1
    Its not possible to retrieve the sequence from the matrix. The matrix has no knowledge of this. Anything over 3 steps most likely also is lost in the matrix, unless you happen to know some of the stages. Still if its not the first in chain that you know and the sequence then there's nothing you can do the data is just lost forever. The matrix does not know the history of the object just its current state. All decompositions are equally valid ways of representing current state, but not how it got there. – joojaa Jan 21 '13 at 10:22
  • Thanks.. I will save the angles separately then – Vinod Paul Jan 21 '13 at 12:39