up to Schedule & Notes

Homogeneous Coordinates

Idea: maps points to a higher dimensional space in which translations are matrix operations.

$\begin{array}{} \textrm{2D} & \rightarrow & \textrm{3D} & \rightarrow & \textrm{3D} & \rightarrow & \textrm{2D} \\ \\ (x,y) & \rightarrow & (kx, ky, k) \\ & & T(kx, ky, k) & \rightarrow & (u,v,w) \\ & & & & (u,v,w) & \rightarrow & (u/w,v/w) \end{array}$

In the initial mapping 2D $\rightarrow$ 3D, typically choose $k=1$, so $(x,y) \rightarrow (x,y,1)$.

Rotation by angle $\theta$: $p' = T \; p$

$T = \left[ \begin{array}{cc} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{array} \right]$

$\begin{eqnarray} \left[ \begin{array}{c} u \\ v \\ w \end{array} \right] & = & \left[ \begin{array}{cc} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{array} \right] \left[ \begin{array}{c} x \\ y \\ 1 \end{array} \right] \\ \\ & = & \left[ \begin{array}{cc} x \cos\theta - y \sin\theta \\ x \sin\theta + y \cos\theta \\ 1 \end{array} \right] \end{eqnarray}$

Then divide by last component, $w$ ($= 1$ above), to get $(x',y')$.

Scaling by $(s_x,s_y)$:

$T = \left[ \begin{array}{cc} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{array} \right]$

Translation by $(t_x,t_y)$:

$T = \left[ \begin{array}{cc} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{array} \right]$

$\begin{eqnarray} \left[ \begin{array}{c} u \\ v \\ w \end{array} \right] & = & \left[ \begin{array}{cc} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{array} \right] \left[ \begin{array}{c} x \\ y \\ 1 \end{array} \right] \\ \\ & = & \left[ \begin{array}{cc} x + t_x \\ y + t_y \\ 1 \end{array} \right] \end{eqnarray}$

Then divide by $w = 1$, to get $(x',y') = (x + t_x, y + t_y)$.

So we can use homogeneous coordinates to make translation, rotation, and scaling all matrix operations, which can be composed.

Don't forget to divide by last component, $w$, to bring back to 2D. up to Schedule & Notes