Here’s the next in the mathematics in action series.

An important group of geometric transformations are the affine transformations, such as translations, reflections, and rotations. They are defined by a combination of a matrix multiplication and a translation:

Such transformations are an important part of the PostScript page description language. For example, the PostScript code below, after the initial header, specifies a black letter F, and another in blue, translated by (50, 50):

```
%!PS-Adobe-3.0
%%BoundingBox: 0 0 196 118
%%Pages: 0
%%DocumentFonts: Times-Roman
%%DocumentNeededFonts: Times-Roman
%%Orientation: Portrait
%%EndComments
%%EndProlog
gsave newpath 100 dict begin /Times-Roman findfont 50 scalefont setfont
gsave 0 setgray 0 0 moveto (F) show grestore
gsave 0 0 1 setrgbcolor 50 50 translate 0 0 moveto (F) show grestore
```

The output is included in this picture:

But of course that is using only the (*e*, *f*) part of the transformation. More interesting is a rotation through an angle θ, where the matrix is:

PostScript allows this to be specified using a translation and a rotation angle in degrees (red F) or as an (*a*, *b*, *c*, *d*, *e*, *f*) matrix which combines the rotation matrix with a (180, 0) translation (grey F):

```
gsave 1 0 0 setrgbcolor 100 0 translate 30 rotate 0 0 moveto (F) show grestore
gsave 0.5 setgray 30 [0.8660 0.5 -0.5 0.8660 180 0] concat 0 0 moveto (F) show grestore
```

A diagonal matrix provides scaling in the *x* and *y* directions, with negative scaling factors giving a reflection. Again, PostScript allows the scaling factors to be provided directly (green F), or as an (*a*, *b*, *c*, *d*, *e*, *f*) matrix (brown F):

```
gsave 0 0.7 0 setrgbcolor 100 100 translate -2 0.5 scale 0 0 moveto (F) show grestore
gsave 0.5 0.3 0 setrgbcolor [-2 0 0 0.5 175 75] concat 0 0 moveto (F) show grestore
end grestore showpage
%%Trailer
%%EOF
```

Copying and pasting the three blocks of PostScript into a text file with a .EPS extension will give the coloured image above, which can be viewed by printing it, or by inserting it into a Microsoft Word document. Experimentation with other, more complex, affine transformations is easy that way.

### Like this:

Like Loading...