From the last lecture: To rotate an object around its centre, we had to translate, then rotate, then translate again.
But these were all separate operations and could not (because translation could not be written as a matrix multiplication) be combined into a single matrix multiplication.
Suppose we could express the translations as matrix operations, so translation by $t$ is done with a matrix multiplication by some matrix, $T_t$.
Then a translation by $-c$ of a point $v$ is $v-c$ and could be written as $T_{-c} v$, where $T_{-c}$ is the matrix that causes a translation by $-c$.
Then the final transformation from the previous lecture is simplified:
$\begin{array}{rll} v''' & = T_{+c} \; (R_\theta \; (T_{-c} \; v)) \\ & = (T_{+c} \; R_\theta \; T_{-c}) \; v & \textrm{because matrix multiplication is associative} \\ & = M v & \textrm{for}\ M = T_{+c} \; R_\theta \; T_{-c} \end{array}$
So the whole chain of transformations can be represented as a single matrix multiplication.
But how can we represent translation as a matrix multiplication?
Homogeneous coordinates allow us to represent translation (and
projection, which we'll talk about later) as matrix multiplication.
$\begin{array}{cccl} \textrm{2D} & & \textrm{homogeneous} \\ \\ (x,y) & \longrightarrow & (k x, k y, k) & \textrm{for any}\ k \neq 0 \\ & & {\Big\downarrow} & \textrm{(linear transforms)} \\ (u/w, v/w) & \longleftarrow & (u, v, w ) \\ & \div w \end{array}$
In 3D:
$\begin{array}{cccl} \textrm{3D} & & \textrm{homogeneous} \\ \\ (x,y,z) & \longrightarrow & (k x, k y, k z, k) & \textrm{for any}\ k \neq 0 \\ & & \Big\downarrow & \textrm{(linear transforms)} \\ (t/w, u/w, v/w) & \longleftarrow & (t, u, v, w ) \\ & \div w \end{array}$
Scale $(x,y)$ by $(s_x, s_y)$:
$\begin{array}{cccl} \textrm{2D} & & \textrm{homogeneous} \\ \\ (x,y) & \longrightarrow & (x, y, 1) & \textrm{easiest to choose}\ k = 1 \\ & & {\Big\downarrow} \\ (s_x\;x, s_y\;y) & \longleftarrow & (s_x\;x, s_y\;y, 1) \\ & \div 1 \end{array}$
Homogeneous transform is:
$\begin{bmatrix} s_x \; x \\ s_y \; y \\ 1 \end{bmatrix} = \begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}$
Rotate $p$ by $\begin{bmatrix} \cdots u \cdots \\ \cdots v \cdots \end{bmatrix} = \begin{bmatrix} u_x & u_y \\ v_x & v_y \end{bmatrix}$.
$\begin{array}{cccl} \textrm{2D} & & \textrm{homogeneous} \\ \\ p = (p_x, p_y) & \longrightarrow & (p_x, p_y, 1) \\ & & {\Big\downarrow} \\ (p \cdot u, p \cdot v) & \longleftarrow & (p \cdot u, p \cdot v, 1) \\ & \div 1 \end{array}$
Homogeneous transform is:
$\begin{bmatrix} p \cdot u \\ p \cdot v \\ 1 \end{bmatrix} = \begin{bmatrix} u_x & u_y & 0 \\ v_x & v_y & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} p_x \\ p_y \\ 1 \end{bmatrix}$
Translate $(x,y)$ by $(t_x, t_y)$:
$\begin{array}{cccl} \textrm{2D} & & \textrm{homogeneous} \\ \\ (x, y) & \longrightarrow & (x, y, 1) \\ & & {\Big\downarrow} \\ (x + t_x, y + t_y) & \longleftarrow & (x + t_x, y + t_y, 1) \\ & \div 1 \end{array}$
Homogeneous transform is:
$\begin{bmatrix} x+t_x \\ y+t_y \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}$
Here is the transformation to rotate a point, $v = (v_x, v_y)$, around a centre, $c = (c_x, c_y)$, by an angle $\theta$:
$\begin{array}{rll} v''' & = (T_{+c} \; R_\theta \; T_{-c}) \; v \\ \\ & = \left( \begin{bmatrix} 1 & 0 & c_x \\ 0 & 1 & c_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & -c_x \\ 0 & 1 & -c_y \\ 0 & 0 & 1 \end{bmatrix} \right) \;\; \begin{bmatrix} v_x \\ v_y \\ 1 \end{bmatrix} \\ \\ & = \begin{bmatrix} \cos\theta & -\sin\theta & -c_x \cos\theta + c_y \sin\theta + c_x \\ \sin\theta & \cos\theta & -c_x \sin\theta - c_y \cos\theta + c_y \\ 0 & 0 & 1 \end{bmatrix} \;\; \begin{bmatrix} v_x \\ v_y \\ 1 \end{bmatrix} \end{array}$
Note that $v'''$ will be a homogeneous vector with three coordinates, so its first two coordinates must be divided by its last coordinate to get back to 2D.
The same transformations can be applied to 3D using analagous $4 \times 4$ homogeneous transforms.