Counteract preceding rotations

In a situation where I have two axis adjacent back to back (let's say a robotic arm) I can sometimes perform two rotations ($R_1, R_2$) such that the resulting position and direction is unchanged.

This is trivial in cases where two axis are identical -- having $R_2 = -R_1$.

In case the axis are orthogonal, there is no solution.

Third case being in between the two, where there is not a solution, but there is a "best" fit.

A more complex situation is having $~15$ of these axis.

What is the proper name for this concatenated rotation (so I can search better) and how would one model a counter rotation? I envision an algorithm along these lines, but I'd like a closed form solution:

For rotations $i$ through $j$

1. Let $k$ = $j$
2. Find best fit rotation for $k$..$j$
3. If this is not a $0$-error solution
• Set $k$ = $k - 1$
• Goto #2

Achieving cumulative rotation of identity is a simplified version. This is more complex because rotations do not start at the same origin. They are concatenated -- so in real world a robot's arm of $15$ degrees of freedom, with each rod being, say, $12$ inches, may collide and prevent the rotation. I'm not worried about this collision for theory purposes.

So for full solution, I need final rotation to be identity, and translation of the last vector to be zero

-
Counter, as in "undo a rotation"? Note that rotation matrices are orthogonal ($\mathbf Q^T=\mathbf Q^{-1}$)... –  Ｊ. Ｍ. Sep 2 '11 at 16:03
Let me see if I can clarify: You have ~15 fixed axes about which you can rotate, and you want to find some non-trivial combination of 2 or more rotations about these axes that gets "close" to the identity? Are you also requiring that you rotate about these axes in order? Are you specifying the initial rotation about axis 1? Interesting problem. –  Craig Sep 2 '11 at 16:40
If the (however many) rotations are about the same origin, the product of rotations is again a rotation, but the axis will not be either of the prior axes. So there will be a single rotation to bring you back. If you multiply the matrices for the rotations and transpose it, you have the rotation matrix to bring you back. –  Ross Millikan Sep 2 '11 at 16:57
I've modified the OP with more information. @JM - of course "undo a rotation" is easy if you're on the same axis. This isn't the situation of my question. –  Mikhail Sep 2 '11 at 17:45
I see; you've quite so many degrees of freedom, I'd be surprised if there's an easy solution... –  Ｊ. Ｍ. Sep 2 '11 at 17:50