[Math] transform a point in 3D

geometry

I'm getting no where with transformation a point in 3D. Given ($\theta, \phi, p$) and ($x,y, z)$, I want to move the point to ($x', y', z'$). I need to rotate the point one degree ($\theta = 1$) then rotate it again ($ \phi=1$) then move it by one unit ($p=1$). In 2D this is trivial and straightforward I need to apply the following
$$
\begin{bmatrix} x' \\ y' \end{bmatrix} =
\begin{bmatrix}
cos \theta & -sin \theta \\
sin \theta & cos \theta
\end{bmatrix}
\begin{bmatrix}
x \\
y
\end{bmatrix}
+
\begin{bmatrix}
p \\
p
\end{bmatrix}
$$

In Wikipedia, there are rotation matrices about the three axises but this is not what I'm looking for. Any suggestions!

Best Answer

If the translation operation is the last step in the chain you can do it using 3x3 matrices. The idea is to calculate the rotations matrices for each rotation and then concatenate the rotations by multiplying the matrices. Once you have the general rotation matrix, just multiply it by the position vector. Last step is to add the translation vector.

The overall process would be:

1.- Calculate θ rotation matrix (x axis):

$R_1 = \begin{bmatrix}1&0&0\\0&cos θ&-sin θ\\0&sin θ&cos θ\end{bmatrix}$

2.- Calculate ϕ rotation matrix (y axis):

$R_2 = \begin{bmatrix}cos ϕ&0&sin ϕ\\0&1&0\\-sin ϕ&0&cos ϕ\end{bmatrix}$

3.- Multiply matrices to get the general rotation matrix:

$R = R_2 * R_1$

Note the reverse product because we want rotation θ to be the first one.

4.- Apply the rotation to point x,y,z and add translation p:

$\begin{bmatrix}x′\\y′\\z′\end{bmatrix} = R*\begin{bmatrix}x\\y\\z\end{bmatrix} + \begin{bmatrix}p_x\\p_y\\p_z\end{bmatrix}$

Note that I am supposing rotation around x and y axis. If you want another rotation axis you'll need to change the rotation matrices.