# How rotate a point around an arbitrary line in 3D?

I have a body with origin at point A which is represented in homogeneous coordinate of matrix 4x4 and I would like to rotate it around an arbitrary vector in 3D space.

I understand how to rotate the body around its own frame axis, but I'm not sure how to rotate it around any vector in space.

For a general point in 3D space, $P=(x,y,z)$, and a vector, $V$, which is defined by a line between two points, $P_1=(x_1,y_1,z_1)$ and $P_2=(x_2,y_2,z_2)$, (i.e. $V=P_2-P_1$), the transformation of the point around that vector by an angle, $\theta$, is given by:

$\left( \begin{array}{c} x' \\ y' \\ z' \\ 1 \\ \end{array} \right)=T^{-1}.R_x{}^{-1}.R_y{}^{-1}.R_z.R_y.R_x.T.\left( \begin{array}{c} x \\ y \\ z \\ 1 \\ \end{array} \right)$

Where:

$P_{transformed}=(x',y',z') \\$

$T=\left( \begin{array}{cccc} 1 & 0 & 0 & -x_1 \\ 0 & 1 & 0 & -y_1 \\ 0 & 0 & 1 & -z_1 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \\$

$R_x=\left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \frac{c}{d} & -\frac{b}{d} & 0 \\ 0 & \frac{b}{d} & \frac{c}{d} & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \\$

$R_y=\left( \begin{array}{cccc} d & 0 & -a & 0 \\ 0 & 1 & 0 & 0 \\ a & 0 & d & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \\$

$R_z=\left( \begin{array}{cccc} \cos (\theta ) & -\sin (\theta ) & 0 & 0 \\ \sin (\theta ) & \cos (\theta ) & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \\$

$d=\sqrt{b^2+c^2} \\$

$U=(a,b,c): \text{A unit vector in the direction of the vector, V.}$

• thank you. is there a name for a theorem that leads to this? Jul 18, 2017 at 2:48