3D Math
DAVID SARMA
Z-axis (roll):
\[
\left( \begin{array}{ccc}
x' \\ y' \\ z' \\ 1 \end{array}
\right)
=
\left( \begin{array}{ccc}
\cos(\theta) & -\sin(\theta) & 0 & 0 \\
\sin(\theta) & \cos(\theta) & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \end{array} \right)
\cdot
\left( \begin{array}{ccc}
x \\ y \\ z \\ 1 \end{array}
\right)
\]
X-axis (pitch):
\[
\left( \begin{array}{ccc}
x' \\ y' \\ z' \\ 1 \end{array}
\right)
=
\left( \begin{array}{ccc}
1 & 0 & 0 & 0 \\
0 & \cos(\theta) & -\sin(\theta) & 0 \\
0 & \sin(\theta) & \cos(\theta) & 0 \\
0 & 0 & 0 & 1 \end{array} \right)
\cdot
\left( \begin{array}{ccc}
x \\ y \\ z \\ 1 \end{array}
\right)
\]
Y-axis (yaw):
\[
\left( \begin{array}{ccc}
x' \\ y' \\ z' \\ 1 \end{array}
\right)
=
\left( \begin{array}{ccc}
\cos(\theta) & 0 & \sin(\theta) & 0 \\
0 & 1 & 0 & 0 \\
-\sin(\theta) & 0 & \cos(\theta) & 0 \\
0 & 0 & 0 & 1 \end{array} \right)
\cdot
\left( \begin{array}{ccc}
x \\ y \\ z \\ 1 \end{array}
\right)
\]
Common order of operations:
\[
\left( \begin{array}{ccc}
x' \\ y' \\ z' \\ 1 \end{array}
\right)
=
\left[ translate \right] \cdot
\left[ yaw \right] \cdot
\left[ pitch \right] \cdot
\left[ roll \right]
\cdot
\left( \begin{array}{ccc}
x \\ y \\ z \\ 1 \end{array}
\right)
\]