# Compose/decompose rotation matrix from/to plane of rotation and angle

I would like to compose/decompose an $n$-dimensional orthogonal rotation matrix (restricting to simple planar rotations, which rotates in the specified plane of rotation, and fixes in the plane orthogonal to the plane of rotation) from/to the two basis vectors of the plane of rotation, and the angle of rotation.

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

For example in $\mathbb{R}^3$ the well-known 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 composing/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$?

• What do you mean by 'compose/decompose a rotation matrix'? I can't understand what your question exactly is, but I suspect that you just need to implement a QR decomposition storing the Householder or Givens parameters explicitly. Aug 16 '16 at 12:57
• I mean composition the following way: given the two basis vectors of the plane of rotation and an angle, create a matrix which represents this rotation. The decomposition is the reverse of that: given the matrix, extract the two basis vectors of the plane, and the angle of rotation. Yes, this can be interpreted as a Givens rotation. Aug 16 '16 at 13:02
• @plasmacel Compute eigenvectors and eigenvalues. Aug 18 '16 at 17:29

I may be misunderstanding the question, but to construct the matrix of a rotation in a given plane, complete the two vectors to a basis using Gram-Schmidt, then conjugate the obvious matrix consisting of a two-by-two block in your question (and identity outside the $xy$ plane). To find the rotation, diagonalize over $\mathbb{C}$ (a rotation matrix is normal, so diagonalizable), you will have ones on the main diagonal, except in two positions, so the plane spanned by those two vectors is the rotation plane, and the angle is the argument of the eigenvalue.