# Decompose rotation matrix to plane of rotation and angle

I would like to decompose an $n$-dimensional orthogonal rotation matrix (restricting to simple rotation with a single plane of rotation) to the two basis vectors of the plane of rotation, and an angle of rotation.

The common method is decomposing the rotation matrix to an axis and angle, but this doesn't work in higher dimensions.

For example in $\mathbb{R}^3$ given the rotation matrix

$R_{xy}=\begin{bmatrix}\cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}$

it's obvious that the plane of rotation is the $xy$-plane spanned by basis vectors $b_0 = (1,0,0)$ and $b_1=(0,1,0)$ and the angle of rotation is $\theta$. However decomposing it mathematically is rather challenging.

What is the solution for a general (restricted to a single, but arbitrary plane) rotation matrix in $\mathbb{R}^n$?

• There's not going to be any "canonical" answer here, because $b_0$ and $b_1$ are not unique. Aug 13 '16 at 22:20
• Also, not every rotation in $n$ dimensions is just a rotation in a plane if $n>3$. Are you restricting your attention to rotations that are? Aug 13 '16 at 22:27
• Yes, I am restricting it to rotations you presented in math.stackexchange.com/a/1890826/207654. I read about Givens rotations and want to broaden my knowledge about them. Aug 13 '16 at 22:31

Given an oriented 2D subspace $\mathsf{\Pi}$ of a real inner product space $V$ and any angle $\theta$, there exists a rotation $R(\mathsf{\Pi},\theta)$ which acts as a rotation by $\theta$ when restricted to $\mathsf{\Pi}$ and acts as the identity map when restricted to the orthogonal complement $\mathsf{\Pi}^\perp$. Since $V=\mathsf{\Pi}\oplus\mathsf{\Pi}^\perp$ is a(n orthogonal) direct sum, every vector is (uniquely) expressible as sum of a vector in $\mathsf{\Pi}$ and a vector in $\mathsf{\Pi}^\perp$, and using linearity this definition allows us to apply $R(\mathsf{\Pi},\theta)$ to any vector. Picking any two orthogonal unit vectors within $\mathsf{\Pi}$ compatible with the orientation and conjoining that with any basis for $\mathsf{\Pi}^\perp$ yields a basis for $V$ with respect to which $R(\mathsf{\Pi},\theta)$ is block diagonal, with the usual $2\times 2$ rotation matrix as one block and the identity matrix of the appropriate dimensions as the other block.

These are called plane rotations. In 3D we usually think of rotations as happening around a rotation axis, however this kind of thinking doesn't generalize to higher dimensions whereas the plane of rotation idea does generalize. Indeed, any rotation $R\in\mathrm{SO}(V)$ is expressible as

$$R=\prod_i R(\mathsf{\Pi}_i,\theta_i)$$

for some oriented, two-dimensional, mutually orthogonal subspaces $\mathsf{\Pi}_1,\cdots,\mathsf{\Pi}_\ell$ and angles $\theta_1,\cdots,\theta_\ell$. (Obviously $\ell\le(\dim V)/2$.) As the $\mathsf{\Pi}$s are orthogonal to each other, the factors in the above product all commute, which is why no order needs to be specified in the product.

Are the set of planes $\{\mathsf{\Pi}_1,\cdots,\mathsf{\Pi}_\ell\}$ an invariant of $R$ or not? Not necessarily. For instance, consider multiplication by $i$ on $\mathbb{C}^2$. Any complex one-dimensional subspace of $\mathbb{C}^2$ (there are a $\mathbb{CP}^1$ worth of them) is a real two-dimensional stable subspace. However, it turns out of the angles $\theta_1,\cdots,\theta_\ell$ are all distinct mod $2\pi$ up to sign, then $\{\mathsf{\Pi}_1,\cdots,\mathsf{\Pi}_\ell\}$ is an invariant.

Indeed, notice that $R^{-1}$ acts the same way but with opposite angles. With a simple picture we can see that $R+R^{-1}$ acts as the scalar $2\cos(\theta_i)$ on $\mathsf{\Pi}_i$. Therefore, $\mathsf{\Pi}_i$ is precisely the $2\cos(\theta_i)$-eigenspace of $R+R^{-1}$. This may not be computationally practical, perhaps more useful for finding the $\theta$-associated stable subspace would be finding the span of the $e^{i\theta}$ and $e^{-i\theta}$ eigenspaces of the complexification $V\otimes_{\mathbb{R}}\mathbb{C}$ and intersecting with $V$. (I don't really think about linear algebra from the practical side though, so this may be unhelpful.)

• What you think what would be computationally the most practical approach to solve this? Aug 13 '16 at 23:46
• iunno $\phantom{}$ Aug 14 '16 at 0:49

This is a surprisingly interesting question. The solution in $\mathbb{R}^3$ is known (for example, by converting the rotation matrix $\mathbf{R}$ to a versors AKA unit quaternions to obtain the axis and the angle, followed by negating and permuting the axis vector components to get an auxiliary vector which can always (assuming a nonzero axis vector) be normalized to get the second basis vector; the third basis vector being the cross product of the other two) but in higher dimensions sounds hard.

It turns out that if $\mathbf{R}$ represents a rotation on a plane ($\mathbb{R}^2$ subspaces) in $\mathbb{R}^n$, then $$\operatorname{Tr}\mathbf{R} = n - 2 + 2 \cos \theta$$ where $\operatorname{Tr}\mathbf{R}$ refers to trace or matrix $\mathbf{R}$, the sum of elements on the main diagonal on the $n\times n$ matrix $\mathbf{R}$. Note that $\mathbf{R}$ must be an orthogonal matrix (orthonormal matrix), i.e. $\mathbf{R}^T\mathbf{R}=\mathbf{I}$. In other words, the rotation angle $\theta$ fulfills $$\cos \theta = 1 - \frac{n - \operatorname{Tr}\mathbf{R}}{2}$$ and since $\sin\theta = \pm\sqrt{1-\cos^2\theta}$, sign depending on which half of full rotation $\theta$ is in, $$\sin\theta = \pm\frac{1}{2}\sqrt{\left(n - \operatorname{Tr}\mathbf{R}\right)\left(4 - n + \operatorname{Tr}\mathbf{R}\right)}$$

(I found it extremely curious and funny that the rotation angle $\theta$ would be so easy to find; it is the main reason I wrote this answer, in the hopes that this joggles some mathematicians mind enough to point us towards an algorithm that can be used to obtain the solution to the problem at hand.)

The problem left is how to find the bivectors defining the plane of rotation.

The Wikipedia article on plane of rotation mentions that the complex roots of the characteristic polynomial of matrix $\mathbf{R}$ correspond to the planes of rotation -- here, we expect only one complex conjugate root pair --; i.e. eigenplanes of the matrix $\mathbf{R}$.

Unfortunately, my math-fu fails me here -- I've never before encountered this type of problem, and I am not a mathematician --, so I am hoping a real mathematician would complete (or fix, if I am in error, as that tends to occur a bit too often) the path to an actual solution algorithm.

• I found an interesting paper about it: hal.archives-ouvertes.fr/hal-00713697v1/document, see page 17. Unfortunately it has multiple geometric algebra expressions in the algorithm which I can't interpret. Aug 16 '16 at 6:21

As long as the rotation is nontrivial, the matrix $R - I$ has rank $2$, and its image is precisely the plane of rotation. So pick two linearly independent columns of $R - I$, and those are your $b_0$ and $b_1$.

This is the same answer as given by "arctic tern," but expressed differently.

If $R$ is an orthogonal rotation matrix (i.e. $R^{-1} = R^T$ and $\det(R) = 1$), then it can be diagonalized via a unitary similarity matrix. The eigenvalues have absolute value $1$, and come in conjugate pairs. And their product must be $1$.

Hence there are $k$ (where $2k \le n$) eigenvalues of the form $\cos(\theta_m) \pm i \sin(\theta_m)$ for $1 \le m \le k$, and $n-2k$ eigenvalues $1$.

Thus $R$ is the product $\prod_{m=1}^{k} R(\Pi_m,\theta_m)$ (as in "arctic tern's" answer), where $\Pi_m$ is the space generated by the eigenvectors corresponding to the eigenvalues $\cos(\theta_m) \pm i \sin(\theta_m)$. (The eigenvectors also come in conjugate pairs, unless $\theta_m = \pi$, so you can take the two real vectors to be the real and imaginary parts of one of them. For the case where the eigenvalues are $-1$ twice, just pick an eigenvector corresponding to each eigenvalue. If any of the $\theta_m$'s are repeated, this representation won't be unique.)

• If I understand well, I need to perform an Eigen decomposition on the rotation matrix to get the eigenvalues and eigenvectors. However it's not clear how I get the two basis vectors and the angle from them. Aug 17 '16 at 12:23
• Get the angles by solving the equation $e^{i \theta} = \text{eval}$ (or $\cos \theta = \text{real part of eval}$). Get the vectors by doing Gram-Schmidt on the real and imaginary part of the corresponding eigenvectors. Aug 17 '16 at 12:26
1. Solve for the eigenvalues $$\lambda_j$$ and eigenvectors $$v_j$$ of your rotation matrix using the numerical algorithm of your choice.
2. The eigenvalues are of the form $$\lambda_j=e^{i\theta_j}$$, for some rotation angle $$\theta_j$$ within some plane of rotation as described in the above answers.
3. The question is what would be that plane of rotation? Well, the corresponding eigenvectors are generally complex as well. As we know, expressions of the form $$e^{i\theta_j}$$ rotate between the real and imaginary axes. We can therefore conclude that the corresponding plane of rotation would be spanned by the real and imaginary parts of the corresponding eigenvetor $$v_j$$.