Unifying Transformations
Our models are lonely. They need a broader world to occupy. They need to be situated near other models to form complex scenes. In an earlier chapter, we learned about three tools for moving models around: rotation, scale, and translation. We will use these transformations to arrange worlds.
The three transformations use three different mathematical operations: translation is vector addition, scaling is vector multiplication, and rotation is a combination of sine and cosine. These differences present a problem: if we want to apply a sequence of transformations, the code that combines them will be messy. 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. The messes will lead to unmaintainable software if we don't find a better way to express transformation sequences.
In this chapter, we develop a unifying system of transformations that will compactly express any mixture of rotations, scales, and translations. The heart of the system is a mathematical structure called a matrix. By the chapter's end, you'll be able to answer the following questions:
- What is a dot product between vectors and 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 notational and performance benefits of transforming via matrices?
- What is a quaternion and why do we need a second way of representing rotations?
Matrices are more complicated than the arithmetic and trigonometry that we used previously. Ultimately, however, the unified system will be simpler and faster. It has been adopted by nearly all graphics systems of the past several decades.