Classic Computer Magazine Archive COMPUTE! ISSUE 39 / AUGUST 1983 / PAGE 208

3-D Color Computer Patterns

George Trepal

Watching your computer trace harmonic visual figures and then rotating the completed patterns can be a most pleasant experience. Use these two programs to plot points, at different speeds, for your patterns.

The computer is capable of turning out interesting and complex Lissajous patterns. Imagine the patterns as being shadows cast by a three-dimensional wire frame on a turntable which can be rotated full circle, 360 degrees. The computer can do this rotation.

Note that the illustrations use small numbers to produce the patterns. Big numbers are much more interesting. One of my favorites is the combination 22 and 21. Numbers higher than 30 exceed the screen resolution and a blob results.

Both programs here use POKE 65495,0. In most Color Computers this POKE speeds up the machine so that it draws faster. Unfortunately, it throws off several important functions such as the ability to make sounds, load or save tapes, or use a printer. To get rid of the speed POKE, you can either press the reset button or POKE 65494,0.

Program 1 lets you rotate the pattern and is rather slow. Program 2 is much faster, but it doesn't allow the pattern to be rotated. Program 2 looks up in a table the place to draw the next line to; this is much faster than calculating,each new position, as Program 1 does.

Program Calculations

Here's a technical description of Program 1. You can skip the math and just enjoy the art, unless you're curious.

Lissajous patterns are formed by a sine wave of frequency X modulating a sine wave of frequency Y. The result has to be plotted on circular coordinates. Rotation of a pattern is done by altering the phase of one wave in relation to the other.

Lines 20 through 90 give the speed POKE, clear variables, and take in parameters.

Lines 100 to 150 are constants used in the calculations. The reason for letting variables represent the constants is speed. The computer has to change a number into its floating point representation before it can work with it. The process is highly complex and takes time. Since BASIC is interpreted rather than compiled, every time the program sees a number it has to change it over. Variables are stored in floating point form, however, and simply have to be looked up in memory. This is much faster.

The delay loop in line 160 can be left out without hurting the program. Some people who have played with the program have been startled by the sudden switch from text to graphic screen and have managed to hit interesting things on the keyboard. The delay gives fingers a fraction of a second to move to a less dangerous position.

Lines 170 to 220 are just setting up parameters. The program will calculate a point and draw a line to it and then repeat the process. Lines 210 and 220 calculate an arbitrary line length. The idea is to achieve a compromise between a slowly drawn, beautiful pattern and a quickly drawn, jagged pattern.

Lines 230 and 240 produce the sine calculations. The multiplier expands the pattern to fill the screen. The number added to the end shifts the pattern so that the center of the pattern is also the center of the screen.

Lines 250 and 260 help to make things look a little better. Leave them out of the program to see why. Line 280 checks to see if you've pressed the space bar and want a new pattern.