Vector rotation

132 Views Asked by At

Given a unit vector and an angle of rotation about the unit vector, how do I quickly compute the rotation matrix.

I know there must be a simple formula, but I have been unable to find it.

1

There are 1 best solutions below

1
On

Assume to work in 3-dimensional space.

Given a unit vector $u = (u_x, u_y, u_z)$, where $u_x^2 + u_y^2 + u_z^2 = 1$, the matrix for a rotation by an angle of $θ$ about an axis in the direction of $u$ is $$ R = \begin{bmatrix} \cos \theta +u_x^2 \left(1-\cos \theta\right) & u_x u_y \left(1-\cos \theta\right) - u_z \sin \theta & u_x u_z \left(1-\cos \theta\right) + u_y \sin \theta \\ u_y u_x \left(1-\cos \theta\right) + u_z \sin \theta & \cos \theta + u_y^2\left(1-\cos \theta\right) & u_y u_z \left(1-\cos \theta\right) - u_x \sin \theta \\ u_z u_x \left(1-\cos \theta\right) - u_y \sin \theta & u_z u_y \left(1-\cos \theta\right) + u_x \sin \theta & \cos \theta + u_z^2\left(1-\cos \theta\right) \end{bmatrix}. $$

This can be written more concisely as $$ R = \cos\theta\mathbf I + \sin\theta[\mathbf u]_{\times} + (1-\cos\theta)\mathbf{u}\otimes\mathbf{u},$$

where $[\mathbf u]_{\times}$ is the cross product matrix of $u$, $\otimes$ is the tensor product and $\mathbf I$ is the Identity matrix. This is a matrix form of Rodrigues' rotation formula, with $$ \mathbf{u}\otimes\mathbf{u} = \begin{bmatrix} u_x^2 & u_x u_y & u_x u_z \\[3pt] u_x u_y & u_y^2 & u_y u_z \\[3pt] u_x u_z & u_y u_z & u_z^2 \end{bmatrix},\qquad [\mathbf u]_{\times} = \begin{bmatrix} 0 & -u_z & u_y \\[3pt] u_z & 0 & -u_x \\[3pt] -u_y & u_x & 0 \end{bmatrix}. $$