Scale With Dots
Graphics cards compute dot products very quickly. For this reason, graphics developers express transformations in terms of dot products instead of scalar arithmetic. The dot product forms aren't nearly as straightforward for humans to read as the scalar forms, but they pave the way to a fast, comprehensive, and tidy system for expressing transformations built on matrices. We start by casting each of the three transformation types as a sequence of dot products, and we'll see later in this chapter how matrices consolidate the dot products.
Earlier we saw that to scale vector \(\mathbf{p}\) is to multiply it component-wise with a vector of factors. Scaling has this vector notation:
Let's explode the vectors so that we can see the scalar components inside them:
Separating the vector multiplication into three separate scalar multiplications may help us see where a dot product may be applied. Do you see anything that looks like a dot product in these equations?
Probably not. Recasting these three multiplications as dot products takes some indirection and imagination. As dot products, these equations would have the following form:
We need to replace each \(\mathbf{?}\) with a vector. In the scalar multiplication form, the second operand is always a component of \(\mathbf{p}\). Therefore let's try dropping \(\mathbf{p}\) in as the second operand:
The three remaining \(\mathbf{?}\) vectors have the job of selecting out a single component of \(\mathbf{p}\) and multiplying it by the appropriate factor. Let's give these each of these vectors a name:
We determine what vectors \(\mathbf{a}\), \(\mathbf{b}\), and \(\mathbf{c}\) must be by rewriting the dot products as more familiar arithmetic operations. First we explode the vectors:
Then we expand the dot products:
Recall that for scaling the x-coordinate, we want \(p'_x = \textrm{factors}_x \times p_x\). What does that tell us about \(\mathbf{a}\)? The first component must be \(\textrm{factors}_x\) and the other two must be \(0\). We substitute these values in the equation \(p'_x\):
The y- and z-components are constructed similarly. In each case, two zeroes are used to cancel out the unwanted parts of \(\mathbf{p}\). Altogether, our scale transformation looks like this when written as dot products:
We've recast scale as a series of dot products, which gets us closer to our goal of building a transformation machine. Now let's recast rotation.