Unifying Transformations
A 3D model needs a world to occupy. It needs to be situated near other models that give it an environment, resources, and companions. In the last chapter, you learned about three tools for situating models: rotation, scale, and translation. We will use these to arrange worlds.
You've seen how the three transformations can be implemented using three different mathematical operations, with translation as vector addition, scaling as vector multiplication, and rotation built on trigonometric functions. These differences present a problem: running a vertex through a sequence of transformations results in messy code. Worlds are built out of many such sequences. A rock is rotated a bit, scaled up, and then translated into place next to a tree. We want to find a fast and expressive system for sequencing transformations.
In this chapter, we propose a grand unifying theory of transformations that will express rotation, scale, and translation using a common set of mathematical operations. By the chapter's end, you'll be able to answer the following questions:
- What is a dot product between vectors and what is its computational significance?
- How can scaling, rotation, and translation be expressed as dot products?
- How do matrices consolidate the calculation of dot products and provide a common interface for all three transformations?
- What are the logical and performance benefits of transforming via matrices?
As with many mathematical endeavors, some of our steps will appear to add unnecessary complexity to what should be simple operations. Ultimately, however, the unified system has been found to be simpler and faster and has been adopted by nearly all graphics systems of the past several decades.