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 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 , 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) and vector . The result of moving from by the vector is point . We can write down this operation using addition of vectors: , where is called a translation vector.
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.
Scaling
Scaling is multiplying of the original coordinates of a dot or a vector by a scalar. It can be written as , where is an initial vector, is a new vector and 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 . In this case, each point of the figure, say , will move to the point represented by the vector . 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 of the original figure.
- If the scalar is equal to , it is obvious that nothing will change after multiplying.
- Now, let's consider the case when the scalar is between and . Similarly to the case of scalars greater than , each point of the figure will move to the head of the vector . 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 of the original figure.
- Finally, let's consider the case when the scalar is lower than , i.e. negative. Same as above, every point moves to the head of . 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 . 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 .
Rotation
Rotation is the rotation of an object by a particular angle from its origin.
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 with coordinates by an angle , you'll get a new vector with coordinates . 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 :
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 can be found if you multiply the rotation matrix by the coordinates of the vector written as a column.
For example, if and the vector is rotated counterclockwise the coordinates of the vector are equal to:
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 . 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 axis and axis.
- In a reflection over the axis, the coordinates of an object stay the same while the coordinates change their signs. It means that if the coordinates of an object were , they'd be after this type of reflection.
- In a reflection over the axis, the coordinates stay the same while the coordinates take on their opposite sign. It means that if the coordinates of an object were , they'd be after this type of reflection.
Let's consider an example of reflection over axis and axis. Imagine, that you had a triangle and applied reflection over axis to it. In this case, the coordinates of the dots didn't change, but the coordinates of these dots changed their signs, so you got a triangle . And if you apply reflection over axis, the coordinates of the dots don't change, but the coordinates of these dots change their signs, so you get 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 direction, shearing in the direction, and shearing in directions.
Let's take a look at the pictures to understand this transformation. At first, you have a rectangle. When you apply shear in direction, the layers of this rectangle which are parallel to the 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 direction, but this time the layers of this rectangle are parallel to the 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 and directions at the same time. In this case, layers of this rectangle are parallel to the axis and shift, and you get a completely new tetragon.
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
- The main types of reflection are reflection over axis and axis.
- The main types of shear are shearing in the direction, shearing in the direction, and shearing in directions.
Now we're ready to solve some problems!