Chapter 14: Geometric Transformations

Composite Transformations

Often we want to apply more than one transform. If we first wanted to scale an object, we could write:

Where is the vector to be scaled, is the scale matrix, and is the scaled vector.

Then, if we wanted to rotate the object, we would write:

Where is the final vector and is the rotation matrix.

In full, we could write:

However, we can also compute the composite matrix , then apply this to and get the same result.

This concept of a composite matrix is essential in graphics applications as it means we can represent the work of two matrices in a single composite matrix.

Thus we can send a single matrix as a uniform for each draw call which can apply multiple transformations to an object.

Note that these transforms are applied right side first!

Thus is different from


So far we have covered rotation, scale, and shear transformations. There is one type of transformation conspiciously missing from this list: translation (or movement).

This is because we have been looking at matrices that transform a point in the following form:

But this kind of transform cannot allow us to move locations. As an example, you can’t multiply the point with any number to move it. To translate something, we need a transform of the form:

There is no way to do this with a 2x2 matrix!

What’s the solution? We could keep track of a separate translation… but the goal here is to represent everything with a matrix. Then we can easily composite transformations.

The solution is to move to a higher dimension.

Recall that a 2D shear looked like:

A 3D shear looks like:

Applied to some 3D vector:

So we set the third or component of our vector to :

Thus by using a 3D transformation matrix and a 3D vector with in the component, we can use a matrix to represent a 2D translation.

This video shows visually how a shear in 3D space works out to be a translate in 2D space:

Affine transformations

By LucasVB (Own work) [Public domain], via Wikimedia Commons

Composite with Translation

For example, we can translate a coordinate by and then rotate by an angle of by using the following composite matrices:

Notice that we’ve added a column of and a row of to the rotation matrix from before. This holds true for other 2D transforms. For example, scale:

and shear-x:

Positions vs. Vectors

This also gives us a tool for distinguishing between positions and vectors.

We want positions to me affected by translation matrices, of course. But if we have something which is geometrically a vector (e.g. a surface normal), we want that to be scaled and rotated by not translated. We can accomplish this by putting a in the component instead of a .

Thus, for vectors:

This extra component is called the homogeneous coordinate. This is because it is typically either or .

What about 3D?

Since we used a third component to represent translations in our 2D coordinate system, it should come as no surprise that we used a fourth component to represent translations in a 3D coordinate system:

3D scale:

3D rotate (around Z axis):