**Introduction:**

This tutorial goes over the the different transformation matrices used in 3D graphics. Most of the time we use 4x4 matrices for 3D graphics because some transformation matrices require 4 columns,
and to compose all the transformations into a single matrix using matrix multiplication, 4x4 matrices are required. Composing transformation matrices into a single matrix and then applying that matrix to all vertices
is much more efficient than repeatedly multiplying matrices unnecessarily.

**Transformation Matrices:**

__Translation matrix:__

Translation matrices are used to move vectors around. A translation matrix has the form:

$$\left[\begin{array}{cccc}1& 0& 0& {T}_{x}\\ 0& 1& 0& {T}_{y}\\ 0& 0& 1& {T}_{z}\\ 0& 0& 0& 1\end{array}\right]$$

When applied to a vector, this has the following effect:

$$\left[\begin{array}{cccc}1& 0& 0& {T}_{x}\\ 0& 1& 0& {T}_{y}\\ 0& 0& 1& {T}_{z}\\ 0& 0& 0& 1\end{array}\right]\left[\begin{array}{c}{V}_{x}\\ {V}_{y}\\ {V}_{z}\\ {1}_{}\end{array}\right]$$
$$=\left[\begin{array}{cc}{V}_{x}& +{T}_{x}\\ {V}_{y}& +{T}_{y}\\ {V}_{z}& +{T}_{z}\\ {1}_{}\end{array}\right]$$

__Scaling matrix:__

Scaling matrices are used to change the sizes of vectors. A scaling matrix has the form:

$$\left[\begin{array}{cccc}{S}_{x}& 0& 0& 0\\ 0& {S}_{y}& 0& 0\\ 0& 0& {S}_{z}& 0\\ 0& 0& 0& 1\end{array}\right]$$

When applied to a vector, this has the following effect:

$$\left[\begin{array}{cccc}{S}_{x}& 0& 0& 0\\ 0& {S}_{y}& 0& 0\\ 0& 0& {S}_{z}& 0\\ 0& 0& 0& 1\end{array}\right]\left[\begin{array}{c}{V}_{x}\\ {V}_{y}\\ {V}_{z}\\ {1}_{}\end{array}\right]$$
$$=\left[\begin{array}{c}{S}_{x}{V}_{x}\\ {S}_{y}{V}_{y}\\ {S}_{z}{V}_{z}\\ {1}_{}\end{array}\right]$$

__Rotation matrix:__

Rotation matrices are used to rotate vectors. In two dimensions, the following matrix can be used to rotate objects:

$$\left[\begin{array}{cc}\mathrm{cos}\left(\theta \right)& -\mathrm{sin}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{cos}\left(\theta \right)\end{array}\right]$$

In 3D, rotation matrices can be created using Euler angles, which rotate on the seperate $x$, $y$,
and $z$. The problem with Euler angles is that it can create unexpected rotations (gimbal lock) if the programmer is not careful.
Quaternions are a more efficient way to create rotations and generate rotation matrices, and are explained more HERE.

**Sources:**

- Wikipedia - Rotation matrix: https://en.wikipedia.org/wiki/Rotation_matrix