# Transformation using matrices

A vector could be represented by an ordered pair (x,y) but it could also be represented by a column matrix:

$\begin{bmatrix} x\\ y \end{bmatrix}$

Polygons could also be represented in matrix form, we simply place all of the coordinates of the vertices into one matrix. This is called a vertex matrix.

Example

A square has its vertexes in the following coordinates (1,1), (-1,1), (-1,-1) and (1,-1). If we want to create our vertex matrix we plug each ordered pair into each column of a 4 column matrix:

$\begin{bmatrix} x_{1} &x_{2} &x_{3} &x_{4} \\ y_{1}&y_{2} &y_{3} &y_{4} \end{bmatrix}= \begin{bmatrix} 1 &-1 & -1 & 1\\ 1 & 1 & -1 & -1 \end{bmatrix}$

We can use matrices to translate our figure, if we want to translate the figure x+3 and y+2 we simply add 3 to each x-coordinate and 2 to each y-coordinate.

$\\\begin{bmatrix} x_{1}+3 & x_{2}+3 &x_{3}+3 &x_{4}+3 \\ y_{1}+2 &y_{2}+2 &y_{2}+2 & y_{2}+2 \end{bmatrix}$

If we want to dilate a figure we simply multiply each x- and y-coordinate with the scale factor we want to dilate with.

$3\cdot \begin{bmatrix} x_{1} &x_{2} &x_{3} &x_{4} \\ y_{1}&y_{2} &y_{3} &y_{4} \end{bmatrix}$

When we want to create a reflection image we multiply the vertex matrix of our figure with what is called a reflection matrix. The most common reflection matrices are:

for a reflection in the x-axis

$\begin{bmatrix} 1 & 0\\ 0 & -1 \end{bmatrix}$

for a reflection in the y-axis

$\begin{bmatrix} -1 & 0\\ 0 & 1 \end{bmatrix}$

for a reflection in the origin

$\begin{bmatrix} -1 & 0\\ 0 & -1 \end{bmatrix}$

for a reflection in the line y=x

$\begin{bmatrix} 0 & 1\\ 1 & 0 \end{bmatrix}$

Example

We want to create a reflection of the vector in the x-axis.

$\overrightarrow{A}=\begin{bmatrix} -1 & 3\\ 2 & -2 \end{bmatrix}$

In order to create our reflection we must multiply it with correct reflection matrix

$\begin{bmatrix} -1 & 0\\ 0 & 1 \end{bmatrix}$

Hence the vertex matrix of our reflection is

$\\ \begin{bmatrix} -1 & 0\\ 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} -1 & 3\\ 2 & -2 \end{bmatrix}=\\ \\\\\begin{bmatrix} (1\cdot -1)+(0\cdot2) & (1\cdot3)+(0\cdot-2)\\ (0\cdot-1)+(-1\cdot2) & (0\cdot3)+(-1\cdot-2) \end{bmatrix}= \begin{bmatrix} -1 & 3\\ -2 & 2 \end{bmatrix}$

If we want to rotate a figure we operate similar to when we create a reflection. If we want to counterclockwise rotate a figure 90° we multiply the vertex matrix with

$\begin{bmatrix} 0 & -1\\ 1 & 0 \end{bmatrix}$

If we want to counterclockwise rotate a figure 180° we multiply the vertex matrix with

$\begin{bmatrix} -1 & 0\\ 0& -1 \end{bmatrix}$

If we want to counterclockwise rotate a figure 270°, or clockwise rotate a figure 90°, we multiply the vertex matrix with

$\begin{bmatrix} 0& 1\\ -1& 0 \end{bmatrix}$

## Video lesson

Rotate the vector A 90° counter clockwise  and draw both vectors in the coordinate plane

$\underset{A}{\rightarrow}=\begin{bmatrix} -1 & 2\\ -1 & 3 \end{bmatrix}$