[Math] How to combine affine transformations into one matrix

image processingmatricestransformation

enter image description here

So from what I understand from this picture, the box is stretched to twice its width. And it is then flipped from the x-axis. And then it is rotated 30 degrees anticlockwise.

So these three transformations are Scaling, then Reflection then Rotation.

How am I supposed to go about answering this problem. Also, it says which homogenous 2d matrix, this is confusing for me because when you convert cartesian coordinates to homogenous coordinates, you are going from 2d – 3d. This question is saying homogenous but it is a purely 2d transformation, I find this confusing.

Any help would be appreciated.

EDIT: Final matrices:

The scaling matrix is… $$\begin{bmatrix}2& 0& 0\\ 0& 1 & 0\\0& 0 & 1\end{bmatrix}$$
The translation matrix is… $$\begin{bmatrix}1& 0& 3\\ 0& 1 & -1\\0& 0 & 1\end{bmatrix}$$
And the Rotation matrix is…$$\begin{bmatrix}\cos(30) & -\sin(30) & 0\\ \sin(30) & \cos(30) & 0\\ 0 & 0 & 1 \end{bmatrix}$$

Is that right? Now you simply matrix multiply?

Best Answer

You can't represent such a transform by a $2 \times 2$ matrix, since such a matrix represents a linear mapping of the two-dimensional plane (or an affine mapping of the one-dimensional line), and will thus always map $(0,0)$ to $(0,0)$.

So you'll need to use a $3 \times 3$ matrix, since you need to represent affine mappings. If you represent the point $[x,y]$ as the vector $(x,y,1)^T$, then the matrix $$ T_{u,v} = \begin{pmatrix} 1 & 0 & u \\ 0 & 1 & v \\ 0 & 0 & 1 \end{pmatrix} $$ represents the translation in the direction $[u,v]$, i.e. $$ T_{u,v} [x,y] = T_{u,v}(x,y,1)^T = (x+u,y+v,1) = [x+u,y+v] \text{.} $$

To find the representation of a linear mapping as a $3 \times 3$ matrix, simply take the $2\times 2$ matrix that represents the mapping in euclidean two-dimensional space, and embedd it into a $3 \times 3$ matrix like this $$ \begin{pmatrix} M & 0 \\ 0 & 1 \end{pmatrix} \text{.} $$ For example, you'd represent a rotation around the origin (which is a linear mapping) as $$ R_\varphi = \begin{pmatrix} \cos\varphi & -\sin\varphi & 0 \\ \sin\varphi & \cos\varphi & 0 \\ 0 & 0 & 1 \end{pmatrix} \text{.} $$ You can use normal matrix multiplication to combine the matrix representation of affice mappings - for example, to rotate around the point $[u,v]$, compute the product matrix $$ T_{u,v} R_\varphi T_{-u,-v} \text{,} $$ which simply says "shift the center of the rotation to the origin, rotate around the origin and shift back".