Creating Mathematical Illustrations

Worth the pain

Creating the illustrations for the torus geodesics page was a challenge. No single program could do everything I needed; the program that generated the geodesic couldn't make a smooth curve, only an aliased bitmap. To make the smooth curve, I traced the bitmap in a vector illustration program. That was only part of the process; it actually took six different programs to create the finished illustrations. (The task might have been easier in Mathematica or Maple, but I didn't have access to them.)

[torus with smooth vector geodesic]

The Theory

The first step in making an illustration is to create two things: a three-dimensional model and a two-dimensional map to wrap around it. We'll assume you have a map of some pleasing curve.

The 3D Part

Create the model. In a 3D modeling program, create a shape and adjust it to best visual effect. Set the surface texture, color, lighting, background, et cetera.

Create the guide image. Next, wrap the 2D map around the model. Is the map positioned well? Can you see all the details you're trying to show? Keep adjusting the model and map until you have a combination that looks good. Save the project. Export this 2D image as guide.image. This pixellated image won't be a part of the final composited image; its only use is to be a guide for drawing a better version.

[2D bitmap of curve map wrapped around torus model]

Create the model template image. The lowest layer in the final composite will be an image of the model sans map. To create it, delete the map from the model, leaving an unmarked surface. Export this 2D image as model.template. Save the 3D project.

[2D bitmap of blank torus model]

The 2D Part

Set up the vector project. In a vector illustration program, import model.template. Create a new layer and import guide.image into it. Align the guide image exactly over the model template. Lock both of these layers. Hide the template layer.

[Guide image. Layers: guide image (locked), template (locked and hidden)]

Trace the guide. Create a new layer. Using a pen tool, trace the complete path of the map's curve.

[Tracing over the guide image. Layers: raw path, guide image (locked), template (locked and hidden)]

When finished, hide the guide image layer and reveal the template layer. This gives a preview of the finished image.

[Raw traced curve over template. Layers: raw path, guide image (locked and hidden), template (locked)]

Hide the hidden parts of the curve. Create a copy of the layer with the traced curve. Hide the original layer. Working in the copy, break the curve where it changes from being visible to being hidden and vice versa. Select the hidden parts and change their style to indicate that they're hidden (I prefer to make them dashed, less saturated, and slightly thinner than their visible counterparts).

[Finished image. Layers: final path, raw path (hidden), guide image (locked and hidden), template (locked)]

Export this image and resize it to the desired final resolution, et voilà, she is done.

Tips

  • Make the model/map semitransparent. This will let you see what's happening on the hidden part of the surface.

  • Export images at two to three times the desired final resolution. Resizing down will smooth out aliasing effects.

  • If you want the final image's background to be transparent, set the model against a uniform background color that isn't used elsewhere in the image. Select and delete that color just before final resizing.

  • If you plan to make more than one illustration using the same model, save the blank model as a separate project.

Practice is More Complex than Theory

When it came to illustrating torus geodesics, the procedure above is only the beginning. The geodesic curves in those images weren't made up from whole cloth; each was generated from a differential solution to the geodesic equation, plotted, and converted into an image. The illustrations are as accurate as I could make them.

The torus model was created in Bryce 3D. I tried Ray Dream Studio and POV-Ray, but neither offered both good output and the mapping mode needed to wrap a 2D map around a torus.

Creating an illustration began with two homebrew Perl scripts: one found good slant values, and another took a slant and generated points along the resulting geodesic. The points were fed into GnuPlot to generate a map. Some maps had to be cleaned in Illustrator and Photoshop before use, and all had to be offset to compensate for Bryce's mapping coördinate system. The offset map was wrapped around the model in Bryce 3D, compositing and tracing were done in Illustrator, and final resizing and conversion to transparent PNG were done in Photoshop.

All told, it took at least sixteen steps to make each illustration, and that doesn't count the extra work that went into most of them. I added a border to the torus to distinguish it from the background. This was done in its own layer (the topmost). Some illustrations had additional curves, and these were done in their own layers. Sometimes it was necessary to split the hidden and visible parts of a curve into their own layers to get correct overlap effects. All this added up, and it wasn't unusual to have ten different layers in one project.

The results were worth the effort. Compare my first illustration attempt with the final result.

Which of these is worthy of inclusion in a published paper?


The Gory Details

These are the steps it took to make one of the simpler illustrations.

  1. Guess an initial slant value.

  2. Refine this value using the 'slant finder' Perl script.

  3. Plug the refined value into a Perl script which finds points along a geodesic. Export points to a text file.

  4. Generate map from points using GnuPlot. If the map isn't acceptable, go back to step 1.

  5. Take a screenshot.

  6. Open Photoshop, create a new image, and paste screenshot. Crop out everything but map. Save.

  7. (optional step) Open Illustrator, tile nine copies of map (to get boundaries right) in a 3×3 grid, create new layer, and trace vector version of map. Remove placed copies of map and save. Back in Photoshop, open Illustrator file and rasterize, then clean up boundaries that don't join smoothly.

  8. Offset map down by 25% to compensate for Bryce's mapping coördinate system. Save.

  9. Open Bryce torus file, duplicate torus, hide original torus, and wrap map around the new one. Adjust rotation of new torus to best display geodesic. Save. Take screenshot.

  10. In Photoshop, create new image and paste screenshot. Crop down to torus. Save. This will be the guide image.

  11. In Illustrator, load the vector template file (i.e., the blank model). The vector template file contains an outline of the torus and a bitmap of a blank torus.

  12. Save under a new name. Import the guide image on a separate layer, align to existing artwork, and lock layer.

  13. Trace path of geodesic. Copy path. Hide and lock layer.

  14. Create new layer and paste path. Cut at control points. Group visible segments of the path and give them a solid line style. Group hidden segments of path and give them a lighter, thinner, dashed style. Save.

  15. Take a screenshot or export to file.

  16. In Photoshop, import screenshot or file and crop. Create a mask channel for transparency. Resize. Save as PNG.

Whew. And that's for a simple illustration.


Last updated 3 November 2004
http://www.rdrop.com/~half/math/torus/illustrating.html
All contents ©2004 Mark L. Irons