# Matrix for rotation around a vector

I'm trying to figure out the general form for the matrix (let's say in $\mathbb R^3$ for simplicity) of a rotation of $\theta$ around an arbitrary vector $v$ passing through the origin (look towards the origin and rotate counterclockwise). This is inspired by a similar problem which asked me to find the matrix for a rotation of $120^\circ$ around the vector $v=\begin{bmatrix}1&1&1\end{bmatrix}^\top$. However, in this case I was able to cheat a little since the transformation corresponds to a rotation of the vertices. So even though I found a solution, I'm not satisfied with my methodology. Is there a general form for rotation around an arbitrary vector in $\mathbb R^3$? A reference would be perfectly acceptable. Thanks.

-

4
Look up the Rodrigues rotation formula. – J. M. May 8 '12 at 21:14
That's exactly what I'm looking for. Thanks. – chris May 8 '12 at 21:35

## 1 Answer

To settle this question: one can use the Rodrigues rotation formula to construct the rotation matrix that rotates by an angle $\varphi$ about the unit vector $\mathbf{\hat u}=\langle u_x,u_y,u_z\rangle$ (and if your vector is not a unit vector, normalization does the trick). Letting

$$\mathbf W=\begin{pmatrix}0&-u_z&u_y\\u_z&0&-u_x\\-u_y&u_x&0\end{pmatrix}$$

the Rodrigues rotation matrix is constructed as

$$\mathbf I+\left(\sin\,\varphi\right)\mathbf W+\left(2\sin^2\frac{\varphi}{2}\right)\mathbf W^2$$

where $\mathbf I$ is an identity matrix.

Conventionally, the scalar multiplying the $\mathbf W^2$ term above is written as $1-\cos\,\varphi$, but this version is more prone to subtractive cancellation when $\varphi$ is near $2k\pi$ ($k$ is an integer), so the expression with the sine is more numerically sound.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 14, "mathjax_display_tex": 2, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9413239359855652, "perplexity_flag": "head"}