translation
scaling
\[ \begin{eqnarray*} \vector{x\\y} &\mapsto& \vector{r \cos\of{\phi+\theta} \\ r \sin\of{\phi+\theta}} \\[2mm] &=& \vector{r \cos\phi \cos\theta - r \sin\phi \sin\theta \\ r \cos\phi \sin\theta + r \sin\phi \cos\theta} \\[2mm] &=& \vector{\cos\theta \cdot x - \sin\theta \cdot y \\ \cos\theta \cdot y + \sin\theta \cdot x} \\[2mm] &=& \matrix{\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta} \cdot \vector{x \\ y} \end{eqnarray*} \]
\[ \vector{x\\y} \mapsto \matrix{\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta} \cdot \vector{x \\ y} \]
Represent transformations as matrices!
\[ \mat{S}\of{s_x, s_y} = \matrix{ s_x & 0 \\ 0 & s_y } \]
\[ \mat{R}\of{\theta} = \matrix{\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta} \]
\[ \mat{T}\of{t_x, t_y} = \matrix{ ? & ? \\ ? & ?} \]
Which transformations can be written as matrices?
VERY useful fact! VERY-VERY useful!
scaling
\[ \matrix{ s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 } \]
rotation
\[ \matrix{\cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1} \]
translation
\[ \matrix{ 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1} \]
Columns of matrix are images of basis vectors!
Apply sequence of affine transformations \(\mat{A}_1, \ldots, \mat{A}_k\)
Concatenate transformations by matrix multiplication
\[ A_k\of{\ldots A_2\of{A_1\of{\vec{x}}}} \;=\; \underbrace{\mat{A}_k \cdots \mat{A}_2 \cdot \mat{A}_1}_{\mat{M}} \cdot \vec{x} \]Precompute matrix \(\mat{M}\) and apply it to all (many!) object vertices. Very important for performance!
What is the matrix representation?
Columns of matrix are images of basis vectors!
Any point \(\vec{C}\) on a line is an affine combination \[(1-\alpha)\vec{A} + \alpha\vec{B}\]
of its endpoints \(\vec{A}\) and \(\vec{B}\).Affine transformation \(\mat{M}\) preserves affine combinations \[ \mat{M}\of{(1-\alpha)\vec{A} + \alpha\vec{B}} \;=\; (1-\alpha)\mat{M}\of{\vec{A}} + \alpha\mat{M}\of{\vec{B}} \]