C.2 How the Diagrams Are Made

The diagrams in this book are created with MetaPost, which is a programming language for making mathematical diagrams. Clicking on any diagram on this site will give you the MetaPost source code of the diagram, so you can see how it’s made.

There are some external files containing definitions, subroutines, etc. which are loaded with a line like ‘input geom;’. To see the contents of these files, see geom.mp, global.mp, and myaxes.mp.

MetaPost can create pdf files, which I convert to svg and gif for displaying on the internet.

C.2.1 Hand Drawn Diagrams

You might be wondering how I created diagrams such as this one from Question 11.2.9: Diagram: horizon 2 That ship is in fact drawn by hand. How did I get that into a MetaPost diagram?

I have a laptop which allows you to draw on the screen with a stylus (a Lenovo X200 Tablet), and some time ago I decided to write a very simple X11 drawing program in C because all the drawing programs I could find were much more complicated than what I wanted – they took up screen space with colour selection and brush size, etc. when all I wanted was to write on the screen like you would with a pen in a notebook to do some rough working out. If you’re interested, you can see the C file at sketch.c. (To compile, use ‘gcc sketch.c -L/usr/X11R6/lib -lX11 -o sketch’.)

When I came across the problem of how to include hand drawn images in MetaPost (including the handwriting in Section 7.1.2: Handwriting), I modified my program to output MetaPost commands. See mpsketch2.c for the source code.