Polygons - an interactive demo of the Wallace-Bolyai-Gerwien theorem

This is a small programm that I wrote to demonstrate the Wallace-Bolyai-Gerwien theorem. You can create an arbitrary polygon (by clicking with the mouse) which will then be transformed (by cutting along straight lines and moving and rotating of the resulting pieces) into a rectangle of the same area and with a predetermined fixed width. More detailed instructions can be found below.

The program was created using the Common Lisp compiler from LispWorks. You can download it from http://weitz.de/files/Polygons.zip (Windows) or http://weitz.de/files/Polygons.dmg (OS X).

You are free to use this software for private or educational purposes. (But you are of course using it at your own risk.) However, redistribution of any kind is not allowed without written permission. If you want to give this program to someone else, point them to the original download location at http://weitz.de/polygons/.


When you start the program, you'll see a pane that's mostly white and a gray rectangle to the right which occupies about 30% of the window's area. The gray rectangle is the "target" and the aim of the program is to cut your (still-to-be-constructed) polygon into pieces that will fit exactly into this target (up to a specific height which can only be determined once you've actually created a polygon).

Click in the white area to specify the corners of your polygon, either clockwise or counterclockwise. Once you click on your first corner for the second time, your polygon is finished. At this point you'll notice that the corners aren't emphasized as circles anymore. You'll also see a dashed horizontal line in the target rectangle: The program has computed your polygon's area and the pieces it is about to create will have to fit exactly into the gray area below the dashed line.

Everything in this program (except for clicking to add polygon corners) is done with the context menu. You can for example always undo the last corner by right-clicking and selecting "Remove last point". (In this case, you can also type Ctrl-z instead.) Or you can select "Restart from scratch" to remove everything you've done so far.

Once you're happy with your polygon, select "Transform the entire polygon" and you can then watch an animation that should end with your polygon neatly chopped into pieces which are stacked in the target rectangle occupying just the right height. You'll notice that the program will cut away triangles from the polygon until it is finished. If you select "Transform only one triangle", only one of these steps is shown. In both cases the program won't accept mouse input while the animation is running. This is on purpose.

Should you encounter a bug, please be so kind to send me an email with information about the problem. In this case it'd be very helpful if you could call "Dump all polygons" from the context menu while the program is still running and send me the file that was written. (It will contain a list of all polygons you entered in your session so that I'll have a chance to reproduce the error you've seen.)