Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Long subject, so I am hoping that explains what I am asking, but still let me elaborate with an example.

Let us assume we have an object as part of a container. Now the container is rotated by certain ROTATIONX, ROTATIONY, ROTATIONZ wrt the universe. Now we need to rotate the object WRT the container by rotationx, rotationy, rotationz such that the rotation of the object WRT the universe (rotx, roty, rotz) is zero. How do we do that?

share|improve this question
add comment

2 Answers

There is theorem stating that in 3 dimensions, the composition of any two rotations in 3d-dimensional space is another rotations. This allows you to solve your problem as follows.

Suppose that from knowing the coordinates of the rotated container, and the coordinates of the container before rotations, you can represent $R=R_z\circ R_y\circ R_x$ by a matrix $$R=\left[\begin{matrix}a&d&g\\b&e&h\\c&f&i\end{matrix}\right]$$ where $R(1,0,0)=(a,b,c)$, $R(0,1,0)=(d,e,f)$ and $R(0,0,1)=(g,h,i)$.

Then the inverse rotation of $R$ is, in matrix form:

$$R^T=\left[\begin{matrix}a&b&c\\d&e&f\\g&h&i\end{matrix}\right]$$

So all you need is an algorithm that decomposes the matrix $R^T$ into its constituent rotations around the $x$-, $y$-, and $z$-axis. A good write-up I found via google is this blog post, along with actual computer code!.

share|improve this answer
add comment

Depending upon how you express rotations, you can just undo them in reverse order. Rotations do not commute. So if you did ROTATIONX, then ROTATIONY, then ROTATIONZ, you can do rotz=-ROTATIONZ, then roty=-ROTATIONY, and finally rotx=-ROTATIONX.

share|improve this answer
    
The issue is that I am working with a 3-d library that applies rotation in a specific order - x, y and then z - can't change this order. So I tried the above but it does not work. –  Roopesh Shenoy Mar 20 '11 at 16:49
    
@Roopesh: I don't understand how your library limits you to a specific order? I mean, can't you just call the function three times? –  Raskolnikov Mar 20 '11 at 17:05
    
@Raskolnikov - Nope.. I am using papervision3d, and it is an object property rather than a method or a function. I tried searching for solutions that let me call it in a particular order, but have not found it. –  Roopesh Shenoy Mar 20 '11 at 17:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.