Transformation Matrices
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 u and
v are always 0.0, and w is
always 1.

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access