# 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 ($R1, R2$) such that the resulting position and direction is unchanged.

This is trivial in cases where two axis are identical -- having $R2 = -R1$.

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

Counter, as in "undo a rotation"? Note that rotation matrices are orthogonal ($\mathbf Q^T=\mathbf Q^{-1}$)... –  Ｊ. Ｍ. Sep 2 '11 at 16:03