\( % Arcus cosine. \def\acos{\cos^{-1}} % Vector projection. \def\projection#1#2{{proj_{#1}\left(#2\right)}} % Vector rejection. \def\rejection#1#2{{rej_{#1}\left(#2\right)}} % Norm. \def\norm#1{{\left\|#1\right\|}} % Cross product. \def\cross#1#2{\mathit{cross}\left(#1,#2\right)} % Dot product. \def\dot#1#2{{#1 \cdot #2}} % Magnitude. \def\mag#1{{\left|#1\right}} \def\group#1{\left(#1\right)}} \def\sbgrp#1{\left\{#1\right\}} \)

Rotation around an arbitrary axis - Explicit matrix representation

The rotation formula implicit matrix representation (as derived here here) \[ \vec{p}'=\rejection{\vec{p}}{\hat{r}}\cos(\alpha) + (\cross{\hat{r}}{\vec{p}}) \sin(\alpha) + \projection{\vec{p}}{\vec{\hat{r}}} \] can be restated as \[ \vec{p}' = R \vec{p} \] using a matrix \[ R = \left[\begin{matrix} t \hat{r}_x^2 + c & t \hat{r}_y \hat{r}_x - s \hat{r}_z & t \hat{r}_x \hat{r}_z + s \hat{r}_y \\ t \hat{r}_x \hat{r}_y + s \hat{r}_z & t \hat{r}_y^2 + c & t \hat{r}_y \hat{r}_z - s \hat{r}_x \\ t \hat{r}_x \hat{r}_z - s \hat{r}_y & t \hat{r}_y \hat{r}_z + s \hat{r}_x & t \hat{r}_z^2 + c \end{matrix}\right] \] with \(c = \cos\alpha\), \(s = \sin\alpha\), and \(t = 1 - \cos\alpha\).

Proof

Given \[ R = \cos(\alpha) I + \sin(\alpha) \widetilde{R} + \group{1 - \cos\group{\alpha}}\group{\widetilde{R}^2 + I} \] let \(c = \cos\alpha\), \(s = \sin\alpha\), and \(t = 1 - \cos\alpha\) and obtain \[ R = c I + s \widetilde{R} + t \group{\widetilde{R}^2 + I} \] Expand \[ R = c \left[\begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{matrix}\right] + s \left[\begin{matrix} 0 & -\hat{r}_z & \hat{r}_y \\ \hat{r}_z & 0 & -\hat{r}_x \\ -\hat{r}_y & \hat{r}_x & 0 \\ \end{matrix}\right] + t \left[\begin{matrix} \hat{r}_x^2 & \hat{r}_x \hat{r}_y & \hat{r}_x \hat{r}_z\\ \hat{r}_x \hat{r}_y & \hat{r}_y^2 & \hat{r}_y \hat{r}_z\\ \hat{r}_x \hat{r}_z & \hat{r}_y \hat{r}_z & \hat{r}_z^2 \end{matrix}\right] \] and rewrite to \[ R = \left[\begin{matrix} t \hat{r}_x^2 + c & t \hat{r}_x \hat{r}_y - s \hat{r}_z & t \hat{r}_x \hat{r}_z + s \hat{r}_y \\ t \hat{r}_x \hat{r}_y + s \hat{r}_z & t \hat{r}_y^2 + c & t \hat{r}_y \hat{r}_z - s \hat{r}_x \\ t \hat{r}_x \hat{r}_z - s \hat{r}_y & t \hat{r}_y \hat{r}_z + s \hat{r}_x & t \hat{r}_z^2 + c \end{matrix}\right] \]