Rotation of axes in arbitrary dimension Given two orthonormal bases $(a_{1}, a_{2})$, $(b_{1}, b_{2})$ of $\mathbb{R}^{2}$, we can express one basis in terms of the other via a rotation angle $\theta$, i.e., we can write
$$\begin{bmatrix}
b_{1}\\
b_{2}
\end{bmatrix}
=
\begin{bmatrix}
\cos \theta & \sin \theta\\
-\sin \theta & \cos \theta
\end{bmatrix}
\begin{bmatrix}
a_{1}\\
a_{2}
\end{bmatrix}.
$$
I am wondering whether it is possible to generalize this formula to arbitrary dimension. Namely, suppose that we have two orthonormal bases $(a_{1}, \dotsc, a_{n})$, $(b_{1}, \dotsc, b_{n})$ of $\mathbb{R}^{n}$. Is it then possible to express one basis in terms of the other and a set of rotation angles? If so, how?
EDIT: My first sentence is wrong unless the two bases have the same orientation.
 A: The best generalization of a rotation in higher dimensions is an orthogonal matrix $A$. It's important to note that such matrices might include a reflection that swaps chirality of the basis (right-handed to left-handed and vice-versa). This is easily characterized by the sign of the determinant (see below). Such a matrix really should be called an orthonormal matrix, but the naming is historical. Such a matrix preserves a non-degenerate symmetric bilinear form (equivalently, by the polarization identity a non-degenerate quadratic form) on $\mathbb{R}^n$. In other words, it preserves distances and hence angles between vectors:
$$
\| Av \| = \| v \| 
\quad\text{and}\quad 
\langle Av, Aw \rangle = \langle v, w \rangle
$$
for all $v, w \in \mathbb{R}^n$.
These matrices form a group called the orthogonal group $\operatorname{O}(n) = \operatorname{O}(n, \mathbb{R})$, which is a subgroup of the general linear group $\operatorname{GL}(n) = \operatorname{GL}(n, \mathbb{R})$, consisting of all invertible matrices.
If we assume that the form is the standard dot product of vectors in $\mathbb{R}^n$, then the condition that characterizes orthogonal matrices is:
$$
A^\top A = I,
$$
where $A^\top$ is the matrix transpose and $I$ is the $n \times n$ identity matrix. Equivalently, this means that for orthogonal matrices,
$$
A^{-1} = A^\top.
$$
Also, as a consequence $(\det A)^2 = 1$, so $\det A = \pm 1$.

If $A = (a_1, \dots, a_n)$ and $B = (b_1, \dots, b_n)$ are two orthonormal bases, then they are orthogonal matrices, when the vectors are considered as columns. This also means that, e.g., $A$ is the change-of-basis matrix from coordinates with respect to the $A$-basis to coordinates with respect to the standard basis ($I$-basis). Hence, the matrix product $B^{-1} A = B^\top A$ converts, $A$-coordinates to $B$-coordinates, and is also a member of $\operatorname{O}(n)$.
What does such a matrix look like? A composition of rotations and possibly a reflection (if $\det A = -1$ meaning that $A$ is orientation-reversing). Rotations happen in $2$-dimensional subspaces, so if we define $k \in \mathbb{N}$ by
$$
k = \biggl\lfloor \frac{n}{2} \biggr\rfloor, 
$$
i.e. $n = 2k$ if $n$ is even and $n = 2k + 1$ if $n$ is odd. There is always an orthonormal basis of $\mathbb{R}^n$ such that the your given orthogonal matrix is similar to an orthogonal matrix with at most $k$ many $2 \times 2$ rotation blocks (such as in your question statement) and the rest diagonal elements $\pm 1$, fixing vectors or reflecting them to their negatives. If you insist, you can take a pair of $+1$ or $-1$ diagonal entries and consider them to be a $2 \times 2$ block as well with rotation angle of $0$ or $\pi$, respectively. This is a canonical form for elements of $\operatorname{O}(n)$. In the special case $n=3$ with orientation-preserving change-of-basis, we have Euler's rotation axis theorem.
Putting this all together, if $C = B^\top A$ is the change-of-basis matrix, then we can find invertible $P \in \operatorname{O}(n)$ such that $P^\top C P = (P^\top B^\top) (A P) = (B')^\top (A')$ is in this canonical form, consisting of a composition of $k$ rotations and zero or one reflection.
A: Yes, it's always possible to decompose an orthogonal operation into rotations and reflections.
There is a proof here:
https://planetmath.org/DecompositionOfOrthogonalOperatorsAsRotationsAndReflections
The basic idea of the proof is to break a linear operation down into rotations and reflections on subspaces using its eigenvectors.
You might want to note that this decomposition is not unique, for example in three dimensions there are various ways we can decompose into rotations, the difference being which axes we rotate about, and which axis is chosen first. One choice is the Euler angles, for example, but other choices can be made.
A: Without going too much into technical details, there are a few things that are useful to observe. First of all one can never parametrise all orthonormal bases with just one or more freely varying quantities (real numbers), since the set of orthonormal bases has two connected components (it consists of two parts, where one cannot continuously move from one part to the other). It you write coordinates for the basis vectors and take the determinant of the resulting square matrix, it always takes values $1$ or $-1$, and both possibilities occur: changing one basis vector to its opposite always produces another basis, and one that is in the other connected component. In your two dimensional example, you overlooked the bases obtained from your initial basis by applying a reflection matrix, which is a matrix that differs from one of your rotation matrices by changing the signs in one column.
Second, for each of the connected components the number of freely varying quantities that are needed to describe an arbitrary basis in the component grows more rapidly than $n$; indeed the number of such quantities is $\binom n2=\frac12(n^2-n)$ (these are the triangular numbers $1,3,6,10,15,21,\ldots$). So even if the transformation of the basis involved is like a rotation (one stays in the same connected component), more is needed than one or a few angles of rotation to describe it precisely. In dimension$~3$ one needs $3$ parameters: two to describe the direction of an axis of rotation, and one more for the angle of rotation about this axis. In higher dimension things rapidly become even more complicated, and even though one can still obtain any rotation like transformation as the result of a sequence of consecutive pure rotations (a notion that can be defined in any dimension), this representation is not unique, so that it becomes pointless to try to find the angles of rotation associated to such a transformation.
However, in spite of these complications, there is a fairly nice uniform way do describe all possible orthonormal bases obtainable from a given one, and which works in all dimensions. An orthogonal reflection is a transformation determined by one direction (a line through the origin) which maps vectors in that direction to their opposites, while it maps all vectors orthogonal to that direction to themselves (so the direction of the reflection is its eigenspace for $-1$, and the hyperplane orthogonal to it its eigenspace for $1$). Clearly any reflection has determinant $-1$. Given two distinct vectors $v,w$ of the same length there is exactly one reflection that sends $v$ to $w$, namely the reflection in the direction given by $w-v$. Now given, in a Euclidean vector space of dimension $n$, an initial and target orthonormal basis, there exists a sequence of at most $n$ reflections, which can be found by an explicit method, that will transform the former into the latter. More precisely the number of reflections needed is $n-d$ where $d$ is the dimension of the subspace of vectors that have identical coordinates with respect to the two bases; although the method does not require knowing this subspace or its dimension$~d$, it will determine $d$ at the end (just by counting the reflections it produced) and the subspace will be the one of vectors orthogonal to all the directions of the reflections involved. (The number of reflections is then easily seen to be minimal for the given total transformation$~\tau$, but the sequence of reflections is generally not unique for$~\tau$; while the method chooses one such sequence, it may choose another sequence given another initial orthonormal basis and its image under$~\tau$.)
The method is quite simple. Work with a "current" orthonormal basis obtained by applying previously found reflections to the initial basis. While this basis differs from the target basis, find the first current basis vector $v_i$ that differs from the corresponding target vector $t_i$, and apply the reflection in the direction given by $t_i-v_i$. Clearly applying that reflection to $v_i$ makes it equal to$~t_i$. The vital point for showing that one advances towards a complete match, is that any vectors that already had identical coordinates for the current and target bases are orthogonal to $t_i-v_i$, so that they retain this property when the current basis is reflected. The subspace of all such vectors then can only grow, and indeed its dimension does grow because $v_i$, having been replaced by its image $t_i$ now also has the property of having identical coordinates for the current and target bases. So ultimately all vectors obtain this property and at this point the current basis equals the target basis.
Note that the existence of this construction has interesting consequences. For instance in $\Bbb R^3$ if one has an orthogonal transformation$~\tau$ of determinant$~1$, then it can be obtained as a product of at most$~3$ reflections, but their number must also be even to get positive determinant; unless $\tau$ is the identity then exactly two reflections are needed to produce$~\tau$, and the dimension of the subspace$~L$ of vectors fixed by$~\tau$ is$~1$. Therefore $\tau$ is a rotation with axis$~L$ (and the angle of rotation is twice the angle between the directions of a pair of reflections that composes to give$~\tau$, which pair is not unique).
