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

2 thoughts on “Apollonian Gaskets with Grasshopper

    • Set the number of sides on the polygon component to 3, so you get a triangle. The termination condition on the hoopsnake component doesn’t seem to work (at least for me), so I manually step through each iteration using the hoopsnake menu. The first few iterations will be very fast. By the time you get to the fifth iteration you have to wait a long time. The result of an iteration can be seen by baking the curve component on the bottom. The next iteration can be seen by baking the region difference component on the right.

Leave a Reply