# Find the rotation axis and angle of a matrix

You have $A^T A = I$. Hence $A$ is a rotation. Since $\det A = 1$, it is proper.

By inspection, $A \begin{bmatrix} 1 \\ 2 \\ 2\end{bmatrix} = \begin{bmatrix} 1 \\ 2 \\2\end{bmatrix}$, which gives the axis of rotation.

Inspection also shows that $\begin{bmatrix} 2 \\ -1 \\ 0 \end{bmatrix}$ and $\begin{bmatrix} 2 \\ 4 \\ -5 \end{bmatrix}$ are orthogonal eigenvectors corresponding to the (repeated) eigenvalue $-1$. Hence we see that the rotation angle is $\pi$.

Explicitly, if we let $R = \begin{bmatrix} 1 & 2 & 2 \\ 2 & -1 & 4 \\ 2 & 0 & -5 \end{bmatrix}$, then $R^{-1} = \frac{1}{405} \begin{bmatrix} 45 & 90 & 90 \\ 162 & -81 & 0 \\ 18 & 36 & -45\end{bmatrix}$, and $R^{-1} A R = \begin{bmatrix} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & -1 \end{bmatrix}$, from which we see that the rotation angle is $\pi$.

The simplest way to find the rotation angle is to take the trace of the matrix, the sum of the diagonal elements. By Cameron Buie's answer this equals $1 + 2\cos(\theta)$ where $\theta$ is the angle of rotation. $\theta$ can then be determined up to sign which will depend on the orientation of the axis of rotation chosen.

For non-symmetric matrices, the axis of rotation can be obtained from the skew-symmetric part of the rotation matrix, $S = .5(R-R^\mathrm{T})$;

Then if $S=(a_{ij})$, the rotation axis with magnitude $\sin\theta$ is $(a_{21},a_{02},a_{10})$.

If a linear transformation $T:\Bbb R^3\to\Bbb R^3$ is a non-trivial rotation, then the set $\{x\in\Bbb R^3:T(x)=x\}$ will be the axis of rotation, since non-trivial rotation about an axis moves every point *except* the points on the axis. Also, if the determinant of $T$ isn't $1,$ then it isn't a rotation (why?), though you've already seen that $\det(A)=1$ in this case.

Here, we're working with the transformation $T(x)=Ax$, so the set $\{x\in\Bbb R^3:T(x)=x\}$ is just the eigenspace of $A$ corresponding to the eigenvalue $1$. If $A$ didn't *have* $1$ as an eigenvalue, we'd know it wasn't a rotation at all (in this case, it does have $1$ as an eigenvalue). If the eigenspace's dimension were greater than $1$, then either it'd be a reflection matrix (if dimension $2$), or the identity matrix (if dimension $3$). The latter is clearly not the case, so it's either a rotation matrix or a reflection matrix. However, if it were a reflection matrix, its determinant would be $-1,$ instead (why?), and so it is a rotation matrix.

**Side Note**: Given any two non-zero vectors $x,y$ in $\Bbb R^3$ with the angle from $x$ to $y$ being $\theta$, we have the following formulas (where $\cdot$ is the dot product and $\times$ is the cross product): $$x\cdot y=\lVert x\rVert\lVert y\rVert\cos\theta\tag{1}$$ $$\lVert x\times y\rVert=\lVert x\rVert\lVert y\rVert\sin\theta\tag{2}$$

To see where $(1)$ and $(2)$ come from, see here and here.

In general, let's suppose we've been given some matrix $A$ corresponding to a rotation in $\Bbb R^3$, and that we want to find its angle of rotation. First, find a basis $\{w\}$ for the axis of rotation (found as above), let $x$ be any non-zero unit vector orthogonal (perpendicular) to $w$, let $y=Ax$. Then both $x$ and $y=Ax$ will be unit vectors. (Do you see why $y$ is a unit vector?), so the formulas $(1)$ and $(2)$ yield the following alternate formulas for our particular $x,y$: $$x\cdot y=\cos\theta\tag{$1'$}$$ $$\lVert x\times y\rVert=\sin\theta\tag{$2'$}$$ Here, $\theta$ is the angle of rotation of $A$. (Do you see why?) From there, we can determine $\theta$. (Do you see how?)

Alternatively, start with $w$ (as above), normalize it to $\hat w$, and then determine an orthonormal basis $B=\{\hat w,v_2,v_3\}$ for $\Bbb R^3$ with the Gram-Schmidt process. Then $$(\hat w\: v_2\: v_3)^TA(\hat w\: v_2\: v_3)=\left(\begin{array}{ccc}1 & 0 & 0\\0 & \cos\theta & -\sin\theta\\0 & \sin\theta & \cos\theta\end{array}\right),$$ which gives us another way to find $\theta$.