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.

I'm working with rotations in n dimensions. I represent these rotations as a sequence of $(n^2 - n)/2$ angles, one for each pair of axes, in a fixed order. I can easily compute a rotation matrix from this, by generating the Givens matrix for each angle, and multiplying these matrices.

The problem is doing it the other way around. Given an orthogonal matrix, how can I retrieve the angles in the right order? I'm using an evolutionary algorithm at the moment, which works reasonably well, but is very slow. It would be good if there were a fast method for calculating an exact solution. Unfortunately, most things I find are limited to the 3d case.

My linear algebra is limited to the very practical. I'm willing to learn, of course, but I need to know where to look first.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I assume your orthogonal matrix $R$ has determinant 1, so it is possible to write it as a product of rotations. Let $e_j$, $j=1\ldots n$, be the standard unit vectors in ${\mathbb R}^n$.

Here's one possible strategy. Take a rotation $R_{1,n}$ in coordinates $1$ and $n$ such that $(R_{1,n} R^{-1} e_n)_1 = 0$, then $R_{2,n}$ in coordinates $2$ and $n$ such that $(R_{2,n} R_{1,n} R^{-1} e_n)_2 = 0$ (noting that you'll still have $(R_{2,n} R_{1,n} R^{-1} e_n)_1 = 0$, and so on until $(R_{n-1,n} \ldots R_{1,n} R^{-1} e_n)_i = 0$ for $i=1,2,\ldots,n-1$. Then $(R_{n-1,n} \ldots R_{1,n} R^{-1} e_n)_n$ must be $\pm 1$. If it's $-1$, change $R_{n-1,n}$ by angle $\pi$ to make it $+1$. Note that, by orthogonality, $R_{n-1,n} \ldots R_{1,n} R^{-1} e_j)_n = 0$ for all $j < n$. Proceed in the same way on the $n-1$ component: $R_{n-2,n-1} \ldots R_{1,n-1} R_{n-1,n} \ldots R_{1,n} R^{-1} e_j = e_j$ for $j=n-1$ and $j=n$. Continue iterating down to $j=2$, obtaining finally $R_{1,2} R{2,3} R_{1,3} \ldots R_{1,n} R^{-1} e_j = e_j$ for $j = 2,3, \ldots, n$. Since, by assumption, the determinant is $1$, this will also be true for $j=1$. Thus $R_{1,2} R_{2,3} R_{1,3} \ldots R_{1,n} R^{-1} = I$, i.e. $R_{1,2} R_{2,3} R_{1,3} \ldots R_{1,n} = R$.

share|improve this answer
    
That's great. It seems to do exactly what I want (and yes, the determinant is 1, I thought orthogonality=rotation, but apparently that's not true). Can you comment on how you came up with this? Is this a specific instance of a standard method, or is this sort of stuff just plainly obvious once you reach a certain level of understanding of Linear Algebra? And in the case of the latter, could you suggest a textbook at about that level? –  Peter Mar 14 '12 at 10:52
    
Well, it's a standard sort of idea in mathematics: break the problem up into small pieces, and do one step at a time. As for a Linear Algebra text to build understanding (not specifically for this problem), you might try Strang: books.google.ca/books?id=8QVdcRJyL2oC –  Robert Israel Mar 14 '12 at 16:55
    
In case anybody else is interested, here is an implementation of this algorithm: github.com/pbloem/Lilian/blob/master/Lilian/src/main/java/org/… –  Peter Apr 5 '13 at 14:19
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.