i
i
i
i
i
i
i
i
118 6. Transformation Matrices
x
1.0 0
0 0.5
y
x
y
x
y
.707 -707
.707 .707
.707 -.353
.707 .353
Figure 6.10. Applying the two transform matrices in sequence is the same as applying the
product of those matrices once. This is a key concept that underlies most graphics hardware
and software.
Example. Suppose we want to scale by one-half in the vertical direction and then
rotate by π/4 radians (45 degrees). The resulting matrix is
0.707 −0.707
0.707 0.707
10
00.5
=
0.707 −0.353
0.707 0.353
.
It is important to always remember that matrix multiplication is not commutative.
So the order of transforms does matter. In this example, rotating first, and then
scaling, results in a different matrix (see Figure 6.11):
10
00.5
0.707 −0.707
0.707 0.707
=
0.707 −0.707
0.353 0.353
.
Example. Using the scale matrices we have presented, nonuniform scaling can
only be done along the coordinate axes. If we wanted to stretch our clock by
50% along one of its diagonals, so that 8:00 through 1:00 move to the northwest
and 2:00 through 7:00 move to the southeast, we can use rotation matrices in
combination with an axis-aligned scaling matrix to get the result we want. The
idea is to use a rotation to align the scaling axis with a coordinate axis, then
scale along that axis, then rotate back. In our example, the scaling axis is the
“backslash” diagonal of the square, and we can make it parallel to the x-axis with