The order of transformations in a PDF document I read the following paragraph in the PDF Reference, 6th edition (2006).

Figure 4.6 shows the effect of the order in which transformations are applied. The figure  shows  two  sequences  of  transformations  applied  to  a  coordinate  system. After each successive transformation, an outline of the letter n is drawn.


I don't understand how step 2 in the second line is gotten by changing the order of the transformations in the first line.
 A: It’s very easy to misinterpret Figure 4.6. It might appear as if each step shows the result of transforming the preceding image, but that’s not what’s being shown. Rather, each step shows the result of re-executing the same operations with a further transformation added to the cascade. Of course there’s no rotation that will produce the Step 2 image on the second line from the Step 1 image, but re-rendering the outline of the ‘n’ after concatenating a rotation to the current transformation does.  
With that in mind, the keys to understanding the effects of the transformations are that, they are applied to the coordinate system, not the points, and that they effectively represent how to map from the new coordinate system to the old, i.e., the inverse of what one might normally think of as the matrix of a coordinate system transformation. When it’s the coordinate system being transformed, points are transformed according to the inverse of that transformation, which together with the preceding means that when transforming a point from user space to device space, it is multiplied by the matrices in reverse order. For example, if, in PDF terms, we scale the $x$-direction by 3 and then rotate counterclockwise by 30°, i.e., set the current transformation to [3 0 0 1 0 0] ct [30 cos 30 sin -30 sin 30 cos 0 0] ct, points are transformed by the matrix $$\left(\begin{bmatrix}\frac{\sqrt3}2&\frac12&0\\-\frac12&\frac{\sqrt3}2&0\\0&0&1\end{bmatrix}\begin{bmatrix}\frac13&0&0\\0&1&0\\0&0&1\end{bmatrix}\right)^{-1}=\begin{bmatrix}3&0&0\\0&1&0\\0&0&1\end{bmatrix}\begin{bmatrix}\frac{\sqrt3}2&-\frac12&0\\\frac12&\frac{\sqrt3}2&0\\0&0&1\end{bmatrix}=\begin{bmatrix}\frac{3\sqrt3}2 & -\frac32 & 0 \\ \frac12 & \frac{\sqrt3}2 & 0 \\ 0&0&1 \end{bmatrix},$$ which transforms the unit square into the following parallelogram: 

(Just to make things more confusing, I’m using the common mathematical convention of points as column vectors so that transformations are effected by left-multiplication by a matrix—the transpose of the PDF convention.) This is pretty much what you have at step 2 in the second sequence illustrated in your question. In effect, by rotating the points first, the scaling transformation becomes a shear.

Here are a couple of other ways to think about what’s going on. The color of a pixel in the page is determined by sampling the graphics. The mapping from page pixel coordinates to those in the graphics is determined by the current transformation, which warps the grid that’s used to locate points in the graphics. After scaling $x$ by 3, for instance, that grid becomes three times as dense in the in the $x$-direction, i.e., it goes from this

to this

which has the effect of stretching the image horizontally on the page. If you then rotate the coordinate system 30° counterclockwise, you end up with this grid:

To determine the color of a pixel on the page, sample the corresponding point in the graphics, using the transformed grid.  
Instead of “pulling” pixels from the graphics to the page, we can instead think of “pushing” the graphics out to the page. This involves warping the graphics grid so that it aligns with the grid on the page, i.e., undoing the transformations that were done to the graphics grid, while bringing the image along through the same transformation. If you imagine warping the last grid so that it is once again uniform and aligned with the page, you should be able to see that the square will be transformed into the paralellogram in the first illustration above. Mathematically, this involves applying the inverse of the transformation that was used to change to coordinate system. As with any compound “undo” operation, the individual changes must be undone in the reverse order in which they were applied, which is why the order of the component transformations is reversed when inverting them.
