Lissajous Demo

by Alexandre Owen Muñiz

Select mode:
Xn = sin(2πn · / )
Yn = cos(2πn · / )

This demo uses XHTML with inline SVG and Javascript, and may not work in some older browsers.

Notes:

When I was young, and books with listings of BASIC programs for various games and amusements were commonplace, I ran across a program that allowed one to use one's computer's primitive graphics to produce lissajous figures. At the time, I ignored it in favor of Wumpus. However, when I got a programmable graphing calculator in high school, short quick programs that produced mathy graphics were interesting to me. And when I recently decided that I wanted to learn how to use Javascript and SVG together, a revival of my graphing calculator lissajous demo seemed like the perfect project.

Lissajous figures can be thought of as a class of shapes formed by a generalization of parametric equations for the circle:

x(t) = sin(θt)
y(t) = cos(φt)

If θ = φ ≠ 0, these equations produce a circle, but if we choose to vary the x and y coördinates at different frequencies we can get the looping Lissajous figures familiar from oscilloscopes. Note that this demo plots these figures using increments that are fractions of the full cycle. The advantage of this from a programming perspective is that the plot is guaranteed to eventually return to the starting point, so the program can stop running. It also allows us to make classes of figures with long segments between points where the segments can be seen not just as "chunkiness" in the plotting of a curve, but as a positive feature. This is the case with the polygon / star mode, and some of the examples.

The amount of time the script takes to update the display is proportional to the least common multiple of denominators of the two fractions. If it takes too long to run, you may need to be a bit more careful with these values.

Nick Johnson's Swarm of Motes demo was very useful as a starting point for working with SVG + Javascript. That page includes the words, "This software is free for you to use in any way whatsoever, and comes with no warranty at all." And now so does this one.

If you have questions or comments, please email me.

HomeRecreational Mathematics