# Rotation around the vector $(1,2,3)^T$.

Find the matrix of the rotation in $\Bbb R^3$ through the angle $\alpha$ around the vector $(1, 2, 3)^T$ . We assume that the rotation is counterclockwise if we sit at the tip of the vector and looking at the origin.

Let $P(\vec x)$ be the linear transformation that rotates the coordinate system such that $z$ axis is in the direction of $(1, 2, 3)^T$, then by using some trignometry,

$P((0,0, 1)^T) = \dfrac1{\sqrt{13}}(1,2,3)^T$, $P((0,1, 0)^T) =(0,\sec \theta,\tan \theta)^T$ and $P((1,0,0)^T) =(\sec \theta,0,\tan \theta)^T$, where $\theta$ is the angle between $(1,2,3)^T$ and $(0,0,1)^T$.

Solving for $\theta$ and using matrix representation of $P$,

$$P(\vec x) = \begin{bmatrix}\dfrac{\sqrt{13}}{3} & 0 &\dfrac1{\sqrt{13}} \\ 0& \dfrac{\sqrt{13}}{3}& \dfrac2{\sqrt{13}} \\\dfrac{-2}{3} & \dfrac{-2}{3}& \dfrac3{\sqrt{13}} \end{bmatrix}\vec x$$

Therefore, I got the final rotation transformation as $T(\vec x) := (P^{-1}\circ R_\alpha \circ P)(\vec x)$, where $$R_\alpha(\vec x) = \begin{bmatrix}\cos \alpha & -\sin \alpha & 0 \\ \sin \alpha & \cos \alpha & 0 \\ 0&0&1\end{bmatrix}.$$

Basically what I did was to rotate the coordinate system with $P$ such that $z$-axis and $(1,2,3)^T$ coincide, then I rotated $xy$-plane by $\alpha$ and then reverted back to original coordinates.

Is this correct ?

Please don't use quaternions or any other voodoo like given here. Please use basic trignometry and linear algebra.

Sorry, normally I don't ask this type of question but I can't verify my results in this case.

• it should be a 1 in the last diagonal place. and the corresponding column in $P$ should be the vector in the direction of the axis of rotation. also $P^{-1}$ should be applied first and $P$ last. but everything else looks fine. – mathreadler Oct 6 '17 at 14:13
• @mathreadler Sorry I incorrectly formatted my matrix. Can you check again ? – user8277998 Oct 6 '17 at 14:17
• Generally this is problem for appllication of [Rodrigues formula][en.wikipedia.org/wiki/Rodrigues%27_rotation_formula]. Hard to say whether it is "voodoo".. – Widawensen Oct 6 '17 at 14:17
• looks better but you need a 1 in the last diagonal spot instead of a 0 or it will become a projection onto the disc of rotation. – mathreadler Oct 6 '17 at 14:19
• are you sure you have an ON system by the way? I am not so sure about it... – mathreadler Oct 6 '17 at 14:21

You can find $R$ as $PSP^{-1}$ where $P$ is a rotation (orthonormal transformation) that maps the $x$-axis to the axial vector $(1,2,3)$, and $S$ is a rotation of angle $\alpha$ around the $x$-axis.

Finding $S$ is easy: $$S = \begin{bmatrix}1&0&0\\0&\cos\alpha&-\sin\alpha\\0&\sin\alpha&\cos\alpha\end{bmatrix}$$

Finding $P$ is more complex. Firstly, $Pe_1={(1,2,3)^T\over\sqrt{1^2+2^2+3^2}}$. Next, we meed to make sure that $Pe_i \perp Pe_j$ for all $i \neq j$, and $|Pe_1|=|Pe_2|=|Pe_3|=1$; for this we can use the cross product: Make $Pe_2={(1,2,3)^T\times e_1 \over |(1,2,3)^T \times e_1|}$, which is the unit vector perpendicular to $e_1$ and $(1,2,3)^T$, and similarly make $Pe_3 = {((1,2,3)^T\times e_1) \times (1,2,3)^T \over |(((1,2,3)^T\times e_1) \times (1,2,3)^T|}$, which is perpendicular to both $Pe_1$ and $Pe_2$ and of unit length. This satisfies all the conditions we need for $P$.

A remark: A key step in finding $P$ is finding a pair of vectors perpendicular to the axial vector and to each other. There is no continuous mapping that does this because of the hairy ball theorem. In spite of that, there are algorithms for doing this (see Yves Daoust's answer).

• How did you find perpendicular of $(1,2,3)^T$ ? – user8277998 Oct 7 '17 at 15:12
• @123 $(1,2,3)^T \times (1,0,0)^T = (0,-3,2)^T$ – ogogmad Oct 7 '17 at 16:53
• @123 corrected typo – ogogmad Oct 7 '17 at 16:56
• Why did you took vector product with $(1,0,0)^T$ not $(0,1,0)^T$ or $(0,0,1)^T$ or something else ? – user8277998 Oct 8 '17 at 15:09
• @123 Any reason to use something else? See the remark. – ogogmad Oct 8 '17 at 22:35