# Transformations

## Overview

I once asked a group of students studying Electrical Principles if they knew what a transformer was. Without hesitation, and with a completely straight face, one of the students responded "A robot in disguise?" This was of course a reference to the cartoon series "The Transformers", which first aired in the mid-1980s and has since that time been reworked in various forms. The "Transformers" in that series were indeed powerful robots, cleverly disguised as some other kind of machine. When danger threatened the human race, the "Transformers" would quickly change from cars or trucks into heavily armed robotic combat machines. The word transformation implies that something will change in some way. In the context of geometry, we are interested in the changes that can affect two- or three-dimensional objects.

There are a number of transformations that can be applied to geometric shapes. The ones in which we are primarily interested in are listed below. Each type of transformation will be described in more detail in the following sections.

• Translation - moving an object from one location to another
• Rotation - turning an object through some angle about a point or axis of rotation
• Reflection - turning an object into a mirror image of itself using some arbitrary axis or plane of reflection
• Scaling - making an object bigger or smaller, while maintaining its shape (i.e. keeping all of its dimensions in the same proportion to one another)
• Shearing - distorting an object by pushing it over in a particular direction

The first three translations mentioned above do not, on their own, change the shape or dimensions of the object to which they are applied. The result of translation, rotation or reflection is thus a new object that is congruent with the original object. In the case of scaling, the shape of the object produced by the transformation is the same as that of the original object, but the dimensions are uniformly increased or decreased by a constant factor. The result of scaling is thus an object that is similar to the original object but not congruent with it. In some cases, the degree of scaling can be different for different axes, in which case the shape of the object will change. Only the final transformation mentioned here (shearing) always alters both the dimensions and the shape of the original object. All of these transformations can be formally described using either algebra or matrix arithmetic.

## Translation

Translation is the simplest kind of transformation, and essentially means changing the location of an object, i.e. moving it from one place to another. Although a translation can be combined with other types of transformation, the translation itself can be thought of as what is called a rigid transformation, because the size and shape of the object remains the same. Every point that defines the object is moved in the same direction, and for the same distance. Another way of describing this would be to say that the same vector is added to each point. In the case of a two-dimensional object this will involve moving each point by a given distance parallel to the x axis, and a given distance parallel to the y axis, as shown below (in the case of a three-dimensional object, movement can also take place parallel to the z axis). Polygon A'B'C'D'E' is identical to polygon ABCDE

The effect of a translation is to "slide" the object to a different location without changing its shape or dimensions. In the above illustration, each point in polygon ABCDE has been moved six places to the right (i.e. parallel to the x axis) and one place up (parallel to the y axis) to produce polygon A'B'C'D'E'. Note that the corresponding points of the transformed object are labeled with the same letters as the original object, but with tick marks next to them. This is a convention often adopted for transformations. Note also that the lines that pass through each pair of corresponding points in the two polygons are parallel. We can express the relationship between the new set of x and y coordinates and the original set of x and y coordinates algebraically:

(x, y) → (x + 6, y + 1)

All of the transformations we talk about on this page can be represented using matrices, and translation is no exception. Unlike the other transformations we will talk about, translation is non-linear, and cannot be achieved by multiplying a position vector matrix by a two-by-two transformation matrix. Instead, matrix addition is used to add the required increments to the x and y (or x, y and z) coordinates of the object to be translated. The position vector matrix contains the coordinate values for the original object, while the transformation matrix (which must have the same number of rows and columns as the position vector matrix) contains the incremental values for each coordinate element. An example of how to use matrix addition to represent this type of non-linear transformation can be seen on the page "Matrices as transformations" in the Algebra section.

## Rotation

Rotation is a rigid transformation in which an object is turned through some angle (the angle of rotation) about a point (in the case of a two-dimensional object) or axis of rotation (in the case of a three-dimensional object). We will concentrate here on two-dimensional objects. The point about which the object is rotated is known as the centre of rotation. It may be within the boundaries of the object or outside them, or it may be on the boundary itself. It may also be one of the points that define the object. In the illustration below, triangle ABC is rotated through ninety degrees about point X to produce triangle A'B'C' (note that by convention, the degree of rotation is measured in the anti-clockwise direction). Triangle ABC is rotated ninety degrees around X to produce triangle A'B'C'

Things to note here include the fact that the distance between centre of rotation X and corresponding points on the triangles ABC and A'B'C' remains the same. The dashed concentric circles have been included here to indicate the paths along which each point on triangle ABC will travel when the triangle is rotated around X. For trivial cases of rotation, the transformation can be expressed algebraically without using trigonometry. For example, the rotation through one hundred and eighty degrees (180°) of a two-dimensional object about the origin could be expressed as follows:

R180 (x, y) = (-x, -y)

For non-trivial cases of rotation, trigonometric functions must be used to find the coordinates of the rotated object. This applies to matrix arithmetic as well. An example of how to use matrix arithmetic to represent the rotation of a two-dimensional object about the origin can be seen on the page "Matrices as transformations" in the Algebra section.

## Reflection

Reflection means that an object is reproduced as a mirror-image of itself in a line (sometimes called the axis of reflection or axis of symmetry) or, in the case of three-dimensional objects, a plane. We will concentrate here on two-dimensional objects. In the case of reflection, it is helpful to think of these objects as images. If an image is reflected in a line, every point of the reflected image is the same perpendicular distance from the line as the corresponding point in the original image, as you can see from the illustration below. Because reflection is a rigid transformation, the reflected image has the same size and shape as the original image. Triangle ABC is reflected in the y axis to produce triangle A'B'C'

The axis of reflection does not have to be the x or y axis. It can be any arbitrary line. Of course, reflection in the x or y axes simplifies things greatly in terms of expressing the transformation algebraically. For reflection in the y axis we can express the transformation as follows:

(x, y) → (-x, y)

Similarly, we can express reflection in the x axis as:

(x, y) → (x, -y)

Algebraic methods of expressing reflection in an arbitrary line exist, but are not within the scope of this discussion since they are usually either relatively complex or involve the use of trigonometric functions that are covered elsewhere. Nevertheless, an example of how to use matrix arithmetic to represent the reflection of a two-dimensional object about the x or y axis, or some arbitrary line for which the slope can be determined, can be seen on the page "Matrices as transformations" in the Algebra section.

## Scaling

Scaling (or resizing) is a linear transformation that usually makes an object bigger or smaller while maintaining its original shape. Because the dimensions of the resized object are different to those of the original, the resized object is not congruent with the original object, but it is similar, since all of the resized dimensions are in proportion to those of the original. All of the internal and external angles of a resized polygon will remain the same. Scaling that does not alter the shape of the original object is called uniform scaling (or isotropic scaling). One way of scaling an object is to multiply the x and y coordinates of each point in the object by a scaling factor, as shown in the illustration below. A scaling factor of two is applied to triangle ABC to produce triangle A'B'C'

A scaling factor is essentially a multiplier. In the above figure, a scaling factor of two (2) has been applied to the x and y coordinates of each point in triangle ABC to produce the similar triangle A'B'C'. The effect is to produce a triangle in which the length of each side has been doubled. Note that the internal angles remain the same (ABC = ∠A'B'C', BCA = ∠B'C'A', and CAB = ∠C'A'B'). A scaling factor that is greater than one will always produce an object that is larger than the original, while a scaling factor that is smaller than one (but greater than zero) will always produce an object that is smaller than the original. A scaling factor of one (1) will produce an object that is identical (i.e. congruent) to the original, although some geometry text books state that a scaling factor of one is not valid. Algebraically, the above transformation could be expressed as follows:

(x, y) → (2x, 2y)

Although we have not mentioned negative scaling factors, they too can be used. If we apply a scaling factor of minus two (-2) to the triangle ABC, we effectively create a scaled up version of triangle ABC and then reflect it in both the x and y axes, as shown below. In fact, a scaling factor of minus one (-1) would simply create a reflection of triangle ABC in the x and y axes that is congruent with triangle ABC. A scaling factor of minus two produces an inverted, enlarged reflection of triangle ABC

You will no doubt have observed that a scaling factor greater than one will not only resize the object, but reposition it at the same time. If we want to anchor an object at one of its defining points, that point must either be located at the origin (0, 0) or our scaling factor must be compensated in some way to ensure that the object remains anchored at the designated point. In the following example, we apply a scaling factor of two (2) to triangle ABC. Because point A lies on the origin of the coordinate system, applying the scaling factor to its x and y coordinates (x = 0, y = 0) will leave it in the same position. Triangles ABC and A'B'C' are both anchored at the origin

Since our original triangle ABC did not have one of its points located at the origin, we would need to use a modified algebraic expression in order to ensure that point A' had the same coordinates as point A. For a positive scaling factor greater than one, we essentially need to subtract the x and y coordinate values of the intended anchor point (in this case point A) from whatever new x and y coordinate values the scaling factor gives us. Algebraically speaking, we can modify our original transformation to anchor the scaled up version of triangle ABC at point A as follows:

(x, y) → (2x - 2, 2y - 1)

The result is shown in the following illustration: Triangles ABC and A'B'C' are both anchored at coordinates x=2, y=1

Just to complicate matters, different scaling factors can be applied to the x, y and (in the case of three-dimensional objects) z coordinates of an object. When this occurs, the transformation will produce a shape that is neither congruent nor similar to the original. Unless the original shape is a square or a rectangle (or in the case of a three dimensional environment, a cube or cuboid), the internal and external angles of the object will change. In all cases, the dimensions of corresponding sides will not all change in the same proportion. In the case of a two dimensional object, the application of different scaling factors to the x and y coordinates produces stretching in one direction or the other, as illustrated below. This process is sometimes referred to as directional scaling (or non-uniform scaling, or anisotropic scaling). A couple of examples are illustrated below. Different scaling factors are applied to the x and y coordinates Scaling is applied only to the y coordinates

In the first example, different scaling factors are applied to the x and y coordinates. A scaling factor of three (3) is applied to the x coordinates, while a scaling factor of one-point-five (1.5) is applied to the y coordinates. The result of this transformation is a triangle that differs in shape from the original triangle, having been stretched more in the x direction than in the y direction. In the second example, a scaling factor of two (2) has been applied to the y coordinates, while no scaling has been applied to the x coordinates (or you could say that a scaling factor of one has been applied to the x coordinates). The transformation again results in a triangle that differs in shape from the original triangle, but this time stretching occurs only in the y direction.

As we have seen, deriving algebraic expressions to represent scaling is relatively straightforward. Examples of how to use matrix arithmetic to represent both isotropic and anisotropic scaling can be seen on the page "Matrices as transformations" in the Algebra section.

## Shearing

For two-dimensional objects, shearing is effectively a scaling transformation in which the size of the scaling factor increases, either in the x direction (i.e. the scaling factor applied to the y coordinate increases in proportion to x) or in the y direction (i.e. the scaling factor applied to the x coordinate increases in proportion to y). The resulting shape is distorted in a way that makes it look as though it has been pushed over in one direction or the other (if the scaling factor varies with y) or pushed either up or down (if the scaling factor varies with x). An example of shearing is shown below. Interestingly, although all of the internal angles of a two-dimensional figure subject to shear will change, the area of the figure will be left unchanged by the transformation. Shearing occurs parallel to the x-axis

The formal definition of shear in a two-dimensional environment describes a transformation in which all points on a given line remain fixed, while any point not on that line is shifted parallel to the line by a distance that is proportional to its perpendicular distance from the line (shear may also be applied to a three dimensional object, but we would be looking at planes being shifted, parallel to some fixed plane). In the above example the fixed line is the x-axis, and the transformation that occurs adds two times the value of y to each value of x in the trapezium ABCD to produce trapezium A'B'C'D'. This can be expressed algebraically as follows:

(x, y) → (x + 2y, y)

Examples of how to use matrix arithmetic to represent shearing transformations can be seen on the page "Matrices as transformations" in the Algebra section.