The plot thickens; transformation and rotation of Hilbert and Sierpinski curves.William Fujimoto.

Personal computers and low cost plotters have opened the door to fascinating graphics for people like me who can now create drawings that would be impossible to produce freehand.

This article describes a method for plotting Hilbert and Sierpinski curves and rotating and transforming them to achieve interesting effects. Hardware

The plotter I use is an Houston Instruments DMP-2. Except for an etch-a-sketch, there is probably not a more basic or "dumber" plotter in existence. The available commands for it are few. They are pen up, pen down, and move one step in one direction. The pen can move in eight directions which are increments of 45 degrees. Think of them as points of the compass (i.e., N, E, S, W and NE, SE, SW, NW).

Unlike some inexpensive plotters currently available, you cannot explicitly tell the pen on this device to move from one arbitrary point to another. It has no "home" or 0,0 point; positions such as these can be reached manually by turning two knobs on the side of the machine until the desired spot is reached.

The DMP-2 has no ASCII character generator nor any built in plots for curves or figures such as circles or squares. These functions must be obtained through software if needed.

Connection to a computer can be made with either parallel or RS-232 lines. I currently use the serial line. In the serial mode a step is made by sending to the DMP-2 a lowercase letter from p through w, and pen up or pen down with lowercase y and z, respectively. For example, a vertical line (direction north) 10 steps long is drawn by sending a pen down and 10 p's--zpppppppppp. To make a diagonal line 5 steps to the southwest, the string zuuuuu would be sent. The resolution of this machine is 200 steps per inch vertically and horizontally.

I have used the DMP-2 with an Apple and at present have it hooked to an Altos 8600 at serial port two. Software

To make Hilbert and Sierpinski plots easily, some language with recursion must be used. Since recursion is not part of Basic or Fortran (Some versions of Basic and Fortran do have recursion, in particular, MBasic, MSX Basic, and PDP-11 Basics.--Ed.) and since the Altos runs under Xenix, I had available the C language with which to write my programs. Pascal and PL/1 are alternatives.

In addition to the two recursive plotting programs themselves, I developed routines in C for drawing circles, point-to-point lines, and lines at any angle and of any length. So, with simple commands, figures of any shape could be made anywhere on the plotter area. These routines are too involved to be described here, but are thoroughly explained in the references. Their use, on the other hand, is straight-forward.

As an example, to draw a hexagon one inch on a side the part of a C program shown in Listing 1 could be implemented. A C function made from those lines could be called as hexagon(). The Plots

Using Wirth's algorithms and the line drawing routines, I was able to make the Hilbert and Sierpinski curves. Notice that the Hilbert has a beginning and an end point, while the Sierpinski is a closed curve. Orders 2 and 6 (Figures 1 and 2) are shown for the Hilberts, and 2 and 4 (Figures 3 and 4) for the Sierpinskis.

Even though these plots are nice in themselves, it occurred to me that giving them some depth might make them more interesting. What would it look like if one of these patterns were, perhaps, painted onto a frozen lake and viewed from the air? I attempted to have the DMP-2 draw this imaginary form.

Using the mind's eye, picture one of the plots being rotated and translated in space. The computer can simulate these motions with matrix transformation. A transformation is a mathematical way of turning and moving points in space as if real shapes were being manipulated. With 4 x 4 arrays and a three-dimensional cartesian coordinate system, projections of these points can be made by the plotter. The result is what one would expect of an object drawn on a flat piece of paper. Again, look in the references on graphics for details (Figure 5).

Now if the point X=0, Y=0, and Z=0 is at the center of the Hilbert plot, then it is possible to stretch it around a sphere (which, you recall, is represented by the equation R.sup.2 = X.sup.2 + Y.sup.2 + Z.sup.2.). Whenever X and Y are within the sphere, a Z is calculated, otherwise Z=0. A transformation moves the apparent viewpoint to the left edge and another tilts it backward producing a surface with a spherical concavity in it. A third transformation gives it the desired perspective (Figure 6).

To make the Hilbert sided box with orders 2 to 6 (see the title illustration), it was just a matter of generating, rotating, and shifting the individual plots. The view is through the middle of the box from a position face on. Other Projects

Curves similar to Sierpinskis and Hilberts that can also be plotted are dragons, flow snakes, and other monster curves.

One other possibility is to synthesize 3-D pictures by looking through red and blue filters at red and blue drawings. Appropriate rotations and translations produce an image with apparent depth.

Another possibility is to have the plotter draw pictures for an animated movie. At one picture per frame and 24 frames per second, the total is 7200 drawings for a five-minute film!