A transformation matrix maps points from one coordinate space into another coordinate space. Cocoa and Quartz use transformation matrices to perform standard graphical display operations such as scaling, rotation, and translation.
The matrix used to accomplish two-dimensional transformations is
described by a 3 × 3 matrix. Figure 1.3 shows
a sample 3 × 3 matrix. Note that
v are always 0.0, and
Figure A-3. A point transformed by a 3 × 3 matrix
The contents of a 3 × 3 matrix transform a pointx,y into a point x’,y’ by means of the following equations:
For example, the matrix shown in Figure 1.4 performs no translation. It is referred to as the identity matrix.
Figure A-4. The identity matrix
Using the formulas discussed earlier, you can see that this matrix would generate a new point x’,y’ that is the same as the old point x,y:
To move an image by a specified displacement, you can perform a translation operation. This operation modifies the x and y coordinates of each point by a specified amount. The matrix shown in Figure 1.5 describes a translation ...