Spirograph

all
This Spirograph algorithm is not a strict interpretation of the physical Spirograph device but it generates some very similar and interesting results. The basic algorithm is to blend three circular equations together. Specifically, for values of i from 0 to 2 pi, an x and a y value are generated with :

x = r1 * cos(nr1 * i + o1) + r2 * cos(nr2 * i + o2) + r3 * cos(nr3 * i + o3);
y = r1 * sin(nr1 * i + o1) + r2 * sin(nr2 * i + o2) + r3 * sin(nr3 * i + o3);

In many ways, this is like having three lines of length (set as r1, r2, and r3) being placed end to end with each one rotated a given number of times (set as nr1, nr2, and nr3). Each of the rotations also can be offset (set by o1, o2, o3).

Two different graphs can be drawn in this way and each of those graphs can be duplicated by changing the number of iterations (o iterations would hide graph). Each iteration can be offset by an angle or have its radius scaled.

top

Screen Shot 2016-08-16 at 1.36.40 PM

Leave a Reply

Your email address will not be published. Required fields are marked *