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:
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?


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.

  • $\begingroup$ This way the $A^{-1}$ will look like $\begin{bmatrix} (v_1)_1 & (v_2)_1 & (v_3)_1 \\ (v_1)_2 & (v_2)_2 & (v_3)_2 \\ (v_1)_3 & (v_2)_3 & (v_3)_3 \end{bmatrix}$ in the $A^{-1}RA$, and I will need to rotate around the $v_1$ axis? $\endgroup$ – Botond Jan 5 '18 at 17:13
  • $\begingroup$ See edits above. $\endgroup$ – John Hughes Jan 5 '18 at 20:27
  • $\begingroup$ Thank you for covering everything. It's much easier to remember (and also to prove) it than the R matrix I've given above. $\endgroup$ – Botond Jan 5 '18 at 23:07
  • $\begingroup$ Actually, the R-matrix you've given above comes from Rodrigues' formula, which is pretty simple to prove. (You can see the proof in Computer Graphics, Principles and Practice, 3rd ed, on which I'm the lead author, among other places.) If you write $$R = c\mathbf I + (1-c) \mathbf {n n^t} + s U$$, where $U = \pmatrix{0 & -c & b \\ c & 0 & -a\\ -b & a & 0}$ is the matrix of the transformation $v \mapsto n \times v$, then it's clear that $Rn = n$, and if $v$ is perp to $n$, then $Rv = cv + (1-c)0 + s n \times v$, which represents rotation by $\theta$ in the plane perpendicular to $n$. $\endgroup$ – John Hughes Jan 5 '18 at 23:46
  • $\begingroup$ I've seen my teacherderiving it on a black board, with vectors and also quaternios, but it was fast and required too much visualization. But I'm going to check your book, it might be understandable. $\endgroup$ – Botond Jan 6 '18 at 0:03

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


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 $$

  • $\begingroup$ This is what I've done so far, but I can't find the M matrix. What properties should the basis vectors satisfy in B? $\endgroup$ – Botond Jan 5 '18 at 16:58
  • 1
    $\begingroup$ @Botond you need two vector orthogonal to n and each other. $\endgroup$ – gimusi Jan 5 '18 at 17:01
  • $\begingroup$ With $v_1=n$, the rotation axis in B will be the $v_1$, right? $\endgroup$ – Botond Jan 5 '18 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.