Understanding 3D transforms and rotations
The transformations are applied in this order: scale, rotation then translation. 
Note that you would need to multiply the matrices in the reverse order to get a single transformation matrix.

For a rotation around one axis you would only need a $2\times 2$ matrix, e.g. a rotation around the z-axis wouldn't change the z-values of the vertices. For $(x,y,z)$ vertices a $3\times 3$ matrix is more convenient since it can hold all rotations. The conversion from $3\times 3$ (orange) to $4\times 4$ is done by adding (green) a $1$ to the bottom right cell and fill the remaining with $0$.

$$
\begin{aligned}
&amp;\begin{bmatrix}
\color{orange}1 &amp; \color{orange}0 &amp; \color{orange}0 &amp; \color{green}0\\
\color{orange}0 &amp; \color{orange}{\cos{\theta}} &amp; \color{orange}{-\sin{\theta}} &amp; \color{green}0 \\
\color{orange}0 &amp; \color{orange}{\sin{\theta}} &amp; \color{orange}{\cos{\theta}} &amp; \color{green}0 \\
\color{green}0 &amp; \color{green}0 &amp; \color{green}0 &amp; \color{green}1\\
\end{bmatrix}\\
R_x = &amp;\begin{bmatrix}
1 &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; \cos{\theta} &amp; -\sin{\theta} &amp; 0\\
0 &amp; \sin{\theta} &amp; \cos{\theta} &amp; 0\\
0 &amp; 0 &amp; 0 &amp; 1
\end{bmatrix}\\
R_y = &amp;\begin{bmatrix}
\cos{\theta} &amp; 0 &amp; \sin{\theta} &amp; 0\\
0 &amp; 1 &amp; 0 &amp; 0 \\
-\sin{\theta} &amp; 0 &amp; \cos{\theta} &amp; 0\\
0 &amp; 0 &amp; 0 &amp; 1
\end{bmatrix}\\
R_z = &amp;\begin{bmatrix}
\cos{\theta} &amp; 0 &amp; -\sin{\theta} &amp; 0\\
\sin{\theta} &amp; 1 &amp; \cos{\theta} &amp; 0\\
0 &amp; 0 &amp; 1 &amp; 0\\
0 &amp; 0 &amp; 0 &amp; 1
\end{bmatrix}
\end{aligned}
$$

A translation vector doesn't fit into this matrix, therefore it is expanded to a 4x4 matrix. This is in order to make translation compatible to the other transformations (This is called Homogeneous coordinates.)

$$
\begin{aligned}
T(d_x, d_y, d_y) &amp;= \begin{bmatrix}
1 &amp; 0 &amp; 0 &amp; d_x\\
0 &amp; 1 &amp; 0 &amp; d_y\\
0 &amp; 0 &amp; 1 &amp; d_z\\
0 &amp; 0 &amp; 0 &amp; 1\\
\end{bmatrix}\\
S(s_x, s_y, s_y) &amp;= \begin{bmatrix}
s_x &amp; 0 &amp; 0 &amp; 0\\
0 &amp; s_y &amp; 0 &amp; 0\\
0 &amp; 0 &amp; s_z &amp; 0\\
0 &amp; 0 &amp; 0 &amp; 1\\
\end{bmatrix}
\end{aligned}
$$

Quaternions are a more complex way to describe rotations which avoids a Gimbal Lock, a situation where you would loose one degree of freedom.

Related questions:


What is the order of transformations when exporting to Collada? 
Could someone please explain gimbal lock?
Apply rotation to camera?