Apollonian Gaskets with Grasshopper

My son and I were recently watching Vi Hart’s wonderful “Doodling in Math Class” Video on Infinity Elephants. Around 1:30 in the video she starts talking about how to draw an Apollonian Gasket in a triangle:

Screen Shot 2016-03-04 at 2.04.59 PM

This got me wondering about how to code this object. It’s not a new challenge. Lot’s of people have done it. You can even search Shapeways to find some amazing 3-D printed, 3-dimensional versions. But I couldn’t find much info on how its done. I did find an old discussion here where they were wondering how to do the same thing. (Nothing really useful there, except some nice references to hyperbolic Geometry-specifically a little paper by David Dumas-with a dead link to a program written by Curt McMullen.)

I’ll use Python when I have to, but my preferred method of construction is with the visual programming language Grasshopper, a plug-in for the CAD program Rhinoceros3D.  Clearly, the object I was trying to replicate is fractal, which means recursion is going to be unavoidable. That’s easy enough in Python, but it sucks in Grasshopper. The only way I know to do recursion in Grasshopper is with a 3rd party component. I think there are multiple options. The one I use is called “Hoopsnake.” It does the job, but for this kind of thing it’s extremely slooowwww. That’s OK, because to replicate the drawing in Vi’s video, I’m only going to do about 5 iterations.

It took a bit of experimenting, but eventually I got it down to a surprisingly small Grasshopper definition. The key was to use the CircleTanTanTan component, which automatically finds the circle that is tangent to three different input curves. For the Grasshopper savvy out there, here’s my definition:

Screen Shot 2016-03-04 at 2.17.06 PM

Here’s what it produces….

Screen Shot 2016-03-04 at 1.55.35 PM

…exactly what I wanted!!

Screen Shot 2016-03-04 at 2.35.06 PM


Once I had that, it wasn’t hard to make all kinds of designs. Here are some Apollonian Spheres.




I even experimented with an Apollonian Pocket Watch Design!

Screen Shot 2016-03-04 at 2.53.01 PM

Apollonian Gaskets with Grasshopper

One thought on “Apollonian Gaskets with Grasshopper

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s