Eric Weeks - personal pages - misc / pictures

Contour plots with trigonometric functions

See the bottom of the page for links to other simple algorithms like this one.
[home] [research]
[software] [pics]
[misc] [about me]

I originally got this idea from a Scientific American column -- the Computer Recreations column sometime in the mid-80's, discussing moire patterns. However, I ended up discovering these interesting non-moire patterns.

Selected as a "Knot a Braid of Links" site, #248 (Oct 27, 2001).

NEW: Download a windows version of this program, written by Luciano Genero. Just click the program and it runs, automatically cycling through various parameters. Hit Esc to end.

These are contour plots of a special trigonometric function. I calculate the function:

z = E sin(A sin(I x) + B cos(J y)) + F cos(C cos (K x) + D sin(L y))

This function has parameters A-F and I-L which I can choose to be whatever I want. If they are all equal to one, you get this picture:

If they are all equal to two, you get this picture:

Both of these pictures are periodic.

The original Scientific American article actually was not about these sorts of pictures. I discovered the nice pictures that formula makes by myself. The article discussed plotting pictures where Z changed so rapidly that you got moire effects, like Z=X^2 + Y^2. I found that I liked these pictures better than I liked the moire pictures.

I made a small animation that wanders somewhat through the different parameters. Click the picture to see the animation.

Also, I started a simple shell script running which varied all of the values randomly, and came up with a wide variety of pictures. Some of them are below. Any values not listed are equal to one (for most of these pictures, I=J=K=L=1 for example).

A=1.86 B=4.43 C=4.77 D=5.34 E=0.77 F=0.28 I=2.17 J=2.05 K=1.17 L=2.13

A=2.86 B=1.78 C=4.61 D=2.80 E=0.48 F=0.51 I=0.91 J=3.00 K=1.75 L=0.67

A=1.70 B=3.87 C=4.78 D=5.29 E=0.59 F=0.49

A=5.98 B=3.09 C=2.35 D=4.79 E+0.47 F=0.49 I=0.88 J=2.70 K=1.29 L=0.43

A=3.90 B=7.10 C=9.30 D=2.90 E=0.84 F=0.84

If you'd like to see more, click on the pictures below:

Click here to see EIGHTEEN more of these pictures. For some reason some people do not seem to be overloaded with yellow and red pictures by this point; if this is you, I put 18 of the best of the rest on that page.


Click here to see the source code. To compile:

gcc -o tplot trigplot3.c -lm


Simple trigonometric plot | Double-trigonometric contour plot | Lissajous figures | Simple diffusion limited aggregation | Spiral triangles | Polar flowers

This page created August 22, 1996.

Current address:
Eric R. Weeks
Department of Physics
Emory University
Atlanta, GA 30322-2430