How to rotate a vector by a given angle about a given axis

1.3k Views Asked by At

Let's call the angle $\theta$, and the axis $\underline{\text{n}}$. I'd like to rotate a 3 dimensional vector $\underline{\text{v}}$ by $\theta$ about the $\underline{\text{n}}$ axis. I know that the rotation matrix $\underline{\underline{\text{R}}}$'s elements are $R_{kl}=\cos(\theta)\delta_{kl}+n_kn_l(1-\cos(\theta))+\sum\limits_{m}\epsilon_{kml}n_m\sin(\theta)$, but I'd like to do it a different way: Transform the vector to a different basis, where $\underline{\text{n}}$ is the z axis, and rotate there:
$\underline{\underline{\text{R}}}\underline{\text{v}}=\underline{\underline{\text{A}}}^{-1}\underline{\underline{\text{R}}}'\underline{\underline{\text{A}}}\underline{\text{v}}$
Where $\underline{\underline{\text{R}}}'=\begin{bmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{bmatrix}$
But I'm having trouble with finding the $\underline{\underline{\text{A}}}$ matrix. Is there an easy way to find it?

2

There are 2 best solutions below

5
On BEST ANSWER

The problem you're having probably arises because given $n$, there's no "natural" way to pick $v_2$ and $v_3$.

Because $n$ is a unit vector, you can regard its "tip" as a point on $S^2$. Then $v_2$, as a vector perpendicular to $n$, is a tangent vector to $S^2$ at the tip of $n$. If there were a continuous way to choose $v_2$ as a function of $n$, you'd have a continuous everywhere nonzero vector field on the 2-sphere, which would contradict the "hairy billiard ball" theorem -- that for every vector field on the 2-sphere, the algebraic sum of the indices at the zeroes of the field is two, hence, there must be someplace where the vector field is zero. So that's a proof that there's no continuous way to get $v_2$ from $n$.

That being said, if you assume that $n$ has a nonzero $z$-component, so $$ n = \pmatrix{a \\ b \\ c} $$ with $c \ne 0$, then there's an easy way to pick $v_2$, namely, $$ w_2 = \pmatrix{-c \\ 0 \\ a}\\ v_2 = \frac{1}{\| w_2 \|} {w_2} $$

Because $c$ is nonzero, the vector $w_2$ is nonzero, so it can be 'normalized' to get $v_2$. You then pick $v_3 = n \times v_2$.

What if the $z$-component of $n$ actually is zero? Then you suppose that the $y$-component is nonzero and do something similar. What if the $y$ and $z$ components are both zero? Then $n = \pm e_1$, and you pick $v_2 = e_2, v_3 = e_3$ and you're done.

Note that this sequence of "what do you do if ...?" things amounts to a piecewise definition of $v_2$ in terms of $n$, and the piecewise-ness is exactly what makes continuity fail.

post-comment addition

Once, starting with $n$, you've produced $v_2$ and $v_3$, I'd be inclined to form a matrix $A$ whose first column is $n$, whose second column is $v_2$, and whose third is $v_3$. (I've altered $n$ above to be a column vector so that this makes more sense.) If you do this, then $A$ will be orthogonal, so that $A^t = A^{-1}$, and
$$ A \pmatrix{1 & 0 & 0 \\ 0 & c & -s \\ 0 & s & c} A^t $$

(where $c = \cos \theta, s = \sin \theta$) will be the rotation matrix you're looking for.

So I've put the rotation in the $yz$-plane rather than in the $xy$-plane. If you want it in the $xy$-plane, you'd want to set the columns of $A$ to be $v_2, v_3, n$, in that order.

3
On

Consider the new basis $B=\{v_1=n,v_2,v_3\}$ and the matrix

$$M=[v_1 \quad v_2 \quad v_3]$$

which represent the change of basis from B to the standard, that is

$$v_S=Mv_B \implies v_B=M^{-1}v_S$$

thus since in the base B the rotation of $v_B$ is given by

$$w_B=R'v_B$$

in the standard basis we have

$$w_B=R'v_B\iff M^{-1}w_S=R'M^{-1}v_S \iff w_S=MR'M^{-1}v_S \iff w_S=Rv_S $$