MathAlgebraLinear algebraVectors and vector spaces

Transformations

2 minutes read

When you make some changes to a geometric shape like moving, rotating, changing its size, reflecting or deforming according to some laws, you apply transformations to this shape. Transformations are based on vectors and matrices and occur in several areas of math like analytic geometry, linear algebra and calculus. Of course, they are essential not only in math but also in computer graphics and development of video games! What are the laws behind these operations? Let's discover them together!

However, before we begin, we have to recall some basic fact that will be used throughout our topic: a point can be viewed as a vector, whose tail is in the origin (0,0)(0, 0) and the head is in the given point.

Translation

A translation moves an object to a different position on the coordinate plane along a given vector. Informally, this means that the point will move along the vector up to its head, i.e. in the same direction and by the distance equal to its length. More formally, we can describe the situation as follows.

Let's fix an arbitrary point on the plane. If we assign a vector to this point, we can assume that we are simply adding two vectors: the vector of our point and the translation vector. The result will be their sum, whose tail is in (0,0)(0, 0), hence, the head of this vector represents the translated point.

Too many words? For the sake of simplicity, let's write vectors as rows, and not columns. Assume we have point (or vector) a=(2,3)a=(2,3) and vector b=(3,1)b=(3,1). The result of moving from aa by the vector bb is point c=(5,4)c=(5, 4). We can write down this operation using addition of vectors: c=a+b\vec{c} = \vec{a} + \vec{b}, where c\vec{c} is called a translation vector.

Translation of a point

That is outstanding, however, we can translate much more than just points. Suppose we are given a certain figure in space. What happens if you add the same vector to each point of the figure? Each point will move in the same direction (in the direction indicated by the added vector) by the same distance (equal to the length of the added vector). Simply put, we will get a shifted copy of the original figure.

Translation of a figure

Scaling

Scaling is multiplying of the original coordinates of a dot or a vector by a scalar. It can be written as b=λa\vec{b} = \lambda \vec{a}, where a\vec{a} is an initial vector, b\vec{b} is a new vector and λ\lambda is a scalar. Since you already know about basic vector operations, let's consider some more complex examples. Let's take a figure in space. What happens if you multiply each point (or vector) of the figure by the same scalar?

  • First, let's consider the case when the scalar is greater than 11. In this case, each point of the figure, say pp, will move to the point represented by the vector λp\lambda p. After that, the distance between any two points of the figure will increase exactly scalar times, which means, we will get a shifted enlarged scalar times copy a,b,ca',b',c' of the original figure.

Scaling a triangle when scalar is bigger than 1

  • If the scalar is equal to 11, it is obvious that nothing will change after multiplying.
  • Now, let's consider the case when the scalar is between 00 and 11. Similarly to the case of scalars greater than 11, each point pp of the figure will move to the head of the vector λp\lambda p. However, in this case, the distance between any two points of the figure will be exactly the old distance times scalar, which means, we will get a shifted reduced scalar times copy a,b,ca',b',c' of the original figure.

Scaling a triangle when scalar is lower than 1

  • Finally, let's consider the case when the scalar is lower than 00, i.e. negative. Same as above, every point pp moves to the head of λp\lambda p. The intuition behind it is as follows. To begin, perform all of the above actions for the absolute value of the scalar. Then it will only be necessary to multiply each point by 1-1. What does this mean geometrically? This means that you will have to reflect the figure symmetrically with respect to the origin, and you'll get the figure a,b,ca'',b'',c''.

Scaling a triangle when scalar is smaller than 0

Rotation

Rotation is the rotation of an object by a particular angle θ\theta from its origin.

Note that the size of an object doesn't change

Rotation of a vector

This transformation seems quite easy, but how to write it using matrices or vectors? Well, let's consider an example. If we rotate a vector a\vec{a} with coordinates (x,y)(x,y) by an angle θ\theta, you'll get a new vector a\vec{a}' with coordinates (x,y)(x',y'). How to find the coordinates of this new vector? The rotation matrix will help you to do it. Elements of this matrix are trigonometric functions of the angle θ\theta:

Rθ=[cos(θ)sin(θ)±sin(θ)cos(θ)]R_\theta= \begin{bmatrix} \cos(\theta) & \mp\sin(\theta) \\ \pm\sin(\theta) & \cos(\theta) \\ \end{bmatrix}

Here, you should select the upper signs if the vector is rotated counterclockwise and the lower signs if the vector is rotated clockwise. The coordinates of the vector a\vec{a}' can be found if you multiply the rotation matrix by the coordinates of the vector a\vec{a} written as a column.

[xy]=[cos(θ)sin(θ)±sin(θ)cos(θ)][xy]\begin{bmatrix} x' \\ y' \end{bmatrix} =\begin{bmatrix} \cos(\theta) & \mp\sin(\theta) \\ \pm\sin(\theta) & \cos(\theta) \\ \end{bmatrix} \cdot \begin{bmatrix} x \\ y \end{bmatrix}For example, if θ=90°\theta = 90\degree and the vector a\vec{a} is rotated counterclockwise the coordinates of the vector a\vec a' are equal to:

[xy]=[cos(90°)sin(90°)sin(90°)cos(90°)][xy]=[0110][xy]=[yx]\begin{bmatrix} x' \\ y' \end{bmatrix} =\begin{bmatrix} \cos(90\degree) & -\sin(90\degree) \\ \sin(90\degree) & \cos(90\degree) \\ \end{bmatrix} \cdot \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 1 & 0 \\ \end{bmatrix} \cdot \begin{bmatrix} x \\ y \end{bmatrix} =\begin{bmatrix} -y \\ x \end{bmatrix}

Reflection

Here's another type of transformation which you see nearly every day when you look in a mirror! Reflection is the mirror image of the original object. It is equal to rotation by 180°180\degree. Being a rotation, the size of an object is not changed by it.

There are many types of reflection, but we'll focus on the two most common types: reflection over xx axis and yy axis.

  • In a reflection over the xx axis, the xx coordinates of an object stay the same while the yy coordinates change their signs. It means that if the coordinates of an object were (x,y)(x,y), they'd be (x,y)(x, -y) after this type of reflection.
  • In a reflection over the yy axis, the yy coordinates stay the same while the xx coordinates take on their opposite sign. It means that if the coordinates of an object were (x,y)(x,y), they'd be (x,y)(-x, y) after this type of reflection.

Let's consider an example of reflection over xx axis and yy axis. Imagine, that you had a triangle ABC\triangle ABC and applied reflection over xx axis to it. In this case, the xx coordinates of the dots A,B,CA,B,C didn't change, but the yy coordinates of these dots changed their signs, so you got a triangle ABC\triangle A'B'C'. And if you apply reflection over yy axis, the yy coordinates of the dots A,B,CA,B,C don't change, but the xx coordinates of these dots change their signs, so you get a triangle ABC\triangle A''B''C''.

Reflection of a triangle

Shear

We've already discussed so many types of transformations! Here's the last type of transformations for now. A transformation that changes the shape of an object is called the shear transformation. It's only the second type of transformations, which changes the shape of an object! In this transformation, the sliding of layers of an object occur. The main types of this transformation are shearing in the xx direction, shearing in the yy direction, and shearing in xyx-y directions.

As you will see in later topics, this is done by multiplying by arbitrary matrices, also known as linear operators. However, that is not something you have to think about at the moment.

Let's take a look at the pictures to understand this transformation. At first, you have a rectangle. When you apply shear in xx direction, the layers of this rectangle which are parallel to the xx axis shift to the right, so you get a new tetragon, whose sides are not perpendicular to each other. Nearly the same thing happens if you apply shear in yy direction, but this time the layers of this rectangle are parallel to the yy axis shift. As a result, you once more get a new tetragon, whose sides are not perpendicular to each other. And of course, you can apply the shear in xx and yy directions at the same time. In this case, layers of this rectangle are parallel to the xx axis and yy shift, and you get a completely new tetragon.

Shearing a rectangle

Several transformations can be applied to the same figure. If a transformation TT consists of two consecutive transformations T1T_1 and T2T_2 it is written as T=T1T2T=T_1\cdot T_2.

Conclusion

Let's sum up all the most important facts you've learned so far:

  • The main types of transformations are translation, scaling, rotation, reflection, and shear.
  • Translation and scaling can be represented using vector operations.
  • Rotation can be represented using a rotation matrix Rθ=[cos(θ)sin(θ)±sin(θ)cos(θ)]R_\theta= \begin{bmatrix} \cos(\theta) & \mp\sin(\theta) \\ \pm\sin(\theta) & \cos(\theta) \\ \end{bmatrix}
  • The main types of reflection are reflection over xx axis and yy axis.
  • The main types of shear are shearing in the xx direction, shearing in the yy direction, and shearing in xyx-y directions.

Now we're ready to solve some problems!

5 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo