Page 197 - Hacking Roomba
P. 197
178 Part II — Fun Things to Do
What Are Spiral Equations?
Now that you have a working robot artist, what are some good things to draw? Due to the
nature of the artist, the subject matter should be:
Continuous: Requiring no pen lifts
Bounded: Existing only within a defined area
Smooth: Having no sudden turns or inflections
If the preceding descriptions sound a little mathematical, that’s because they are. Many mathe-
matical curves can be quite beautiful and complex. Some of the easiest types to draw are the
curves created by a Spirograph.
Spirograph is a toy by Hasbro that has been around for about 40 years. It consists of a set of
plastic gears and plastic rings. By placing a smaller gear against a larger gear, inserting a pen
into one of the gears, and moving the pen around according to how the shapes interact, you
can produce neat geometric art. They are great fun. You should get one to play around with
and experience the variety of curves it can produce.
SpiroExplorer is a Processing sketch that uses similar concepts to the ones employed by the
Spirograph, albeit with modifications necessary to operate on a screen. Figure 9-10 shows a
diagrammatic representation of a Spirograph. Instead of gears, imagine circles that move with-
out slip against each other. The larger outer circle is fixed, with radius R. Inside of it moves a
circle of radius r. Anchored to the moving circle is the pen, some distance d from the center of
the moving circle.The pen distance d can be larger or smaller than the smaller circle r (although
in the original Spirograph usually d<r and r<R). By varying the values of R, r, and d, you can
create a wide variety of interesting looking curves. Some of the types of curves obtained are
shown in Figure 9-11.
For another take on generating Spirograph-style art, see www.wordsmith.org/~anu/
java/spirograph.html.
Parametric Curves
The curves a Spirograph produces can be described by a fairly simple set of equations. The
simplest manner of representation is as parametric equations. A parametric equation is one that
just takes in a couple of values (parameters) and outputs other values. One of the simplest para-
metric equations is for a circle. Any point x,y on a circle of radius r can be obtained with the
equation:
x^2 + y^2 = r^2