Image for post
Image for post
a = 7; b = 2;

How I Created Spirographs in Excel

Exploring parametric equations using Excel

You can find the how-to below Excel sheet included…

Growing up I had a toy called a spirograph which was passed down from my parents. I loved it. It generated complex patterns and the stencils would go around and around the circle. At 8 years old, it was quite magical.

Image for post
Image for post
Source

It was simple to use. I’d use the gear with multiple holes inside the larger doughnut ring and place the pen in a hole and generate these patterns.

Image for post
Image for post
Source

20 years later, my tools have changed a little bit. Yet, I’ve found that my love for complex patterns hasn’t changed. Yes, I’ve found new frameworks to discover these patterns. And it doesn’t fail to amaze me what you can do and where the imagination can go. Generally, I’d be using the Processing library from the Processing Foundation (a simplified form of Java) to generate some beautiful images here. There are others out there as well such as OpenFrameworks, Nannou, and Cinder.

But I used something quite different this time. It started while I was working through a statistics book and I was reintroduced to parametric equations. So I started exploring them a more by running the equations through Excel and plotting them as this was to verify the reading and gain some intuition and better understand parametric equations.

Image for post
Image for post
a = 10; b = 2

Parametric Equations

A parametric equation is simply an alternative way to view a function. Generally used in kinematic problems (basic physics problems) problems or equations to describe a property such as the trajectory of a rocket or the orbit of a planet orbiting around a body of mass.

Consider the following function which creates a parabola.

Image for post
Image for post
Image for post
Image for post
Graph of a parabola (y = x²)

Now to take that function, we can decompose (using highschool algebra) the above equation by isolating X and Y by itself and generating a separate parameter whose input is t as the following functions show.

Image for post
Image for post
Image for post
Image for post
Two parametric functions of a parabola

Essentially if you create a table of these two interpretations of the function; they yield the same answer.

Image for post
Image for post
Image for post
Image for post
Normal function (left) and Parametric function (right)

Straight forward right?

Essentially when you use two functions to generate your X and Y coordinates we can produce a large corpus of graphics that you have seen throughout this post. (Mind you this is just one set of equations) as you we see further below.

Image for post
Image for post
Image for post
Image for post
a = 23; b = 2
Image for post
Image for post
Image for post
Image for post
a=5; b=30
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
a=5; b=2.51

So now to the fun part, following I’ve outlined the process in which I generated all of the many shapes throughout this post.

How to create in Excel

  1. Open a new sheet and create the following in your sheet.
Image for post
Image for post

2. For all of the images in this post, I have added the coefficients a, b to the figure legend, and spaced out the (2 ≥ t ≤ 2000) which I just pulled down in my sheet.

3. For X use the following formula starting in C6

=($C$2-$D$2)*COS(B6)+$D$2*COS(B6*(($C$2/$D$2)-1))

4. For Y use the following formula starting in D6

=($C$2-$D$2)*SIN(B6)-$D$2*SIN(B6*(($C$2/$D$2)-1))

5. Pull down all of the formulas so that X and Y are populated down t=2000 and highlight X and Y.

6. Go to the home ribbon and select scatterplot and press scatter (XY) with smooth lines.

Image for post
Image for post

Note you can also change the chart type and it looks something like this:

Image for post
Image for post

7. Now remove the X and Y axis, and readjust the size of the image so that you have an image that you find interesting.

Image for post
Image for post

And then you have your image which then can be exported as an image. Now you can play with it by adjusting the coefficients to change up the different structures the parametric images create. Also, you can change the background color and image to new colors by selecting the component of the image to change and use the format tools and selecting the shape fill and shape outline.

Image for post
Image for post

Or you can download the Excel sheet from Dropbox.

Image for post
Image for post

So in order to add text, use any picture editor or even in Excel which you can then either screenshot or export the image which then can be used in your artwork.

Image for post
Image for post
Image for post
Image for post
a=5; b=1
Image for post
Image for post

I’m a data scientist and software engineer who graduated from RIT interested in solving problems, gen art, data vis, biology, and philosophy.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store