How to find the orthonormal transformation that will rotate a vector to the x axis?

I am having trouble remembering linear algebra. I need to find the orthonormal transformation that will rotate a 3-dimensional vector to the x axis. I could not find any similar question on the net. Any tips?


Solution 1:

Here's how I'd think about it.

Start with your arbitrary vector $\vec{v} = (x,y,z)$ (thought of as a column vector). First, we're going to rotate it to be in the $xy$ plane. We'll achieve this with a matrix of the form $$A=\begin{bmatrix} 1&0&0\\0 &\cos(\theta) & -\sin(\theta)\\ 0 & \sin(\theta) & \cos(\theta)\end{bmatrix}.$$

Applying this to $\vec{v}$ rotates $\vec{v}$ about the x-axis, giving the vector $$A\vec{v} = (x,\text{ }\cos(\theta)y - \sin(\theta)z,\text{ }\sin(\theta)y+\cos(\theta)z).$$ This will lie in the $xy$ plane precisely when the $z$ component is $0$, so we need to pick $\theta$ so that $\sin(\theta)y + \cos(\theta)z = 0$.

Solving this for $\theta$ gives $\theta = \arctan(-\frac{z}{y})$, so we actually know $A$. (There is some ambiguity in using $\arctan$ owing to the fact that $\tan$ is not 1-1. Turns out, if you use a different $\arctan$ function, then end result of $A\vec{v}$ may be different, but will still be in the $xy$ plane.)

Next, we're going to rotate this new vector to be on the $x$-axis. To do this, we'll use a matrix of the form $$B = \begin{bmatrix} \cos(\alpha) & -\sin(\alpha) & 0\\ \sin(\alpha) & \cos(\alpha) & 0\\ 0 & 0 &1\end{bmatrix}.$$

Applying $B$ to our new vector $A\vec{v}$ gives $$BA\vec{v} =(\cos(\alpha)x -\sin(\alpha)[\cos(\theta)y - \sin(\theta)z],\text{ }\sin(\alpha)x + \cos(\alpha)[\cos(\theta)y -\sin(\theta)z],\text{ }0).$$

This will lie along the $x$ axis when the $y$ component is $0$, i.e., when $\sin(\alpha)x + \cos(\alpha)[\cos(\theta)y - \sin(\theta)z]=0$. Solving this for $\alpha$ gives $\alpha = \arctan(-\frac{\cos(\theta)y-\sin(\theta)z}{x}),$ so we know the matrix $B$ as well.

To achieve this via a single orthogonal transformation, use $$BA = \begin{bmatrix} \cos(\alpha) & -\sin(\alpha)\cos(\theta) & \sin(\alpha)\sin(\theta)\\ \sin(\alpha) & \cos(\alpha)\cos(\theta) & -\cos(\alpha)\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta)\end{bmatrix}$$ where $\alpha$ and $\theta$ are as above.