From Mandelbrot’s ‘Fractals:Form, Chance, & Description’:

To construct a circle tangent to three given circles constitutes one of the geometric problems that tradition attributes to Apollonius of Perga. Begin with three gray circles tangent two by two, forming a circular triangle, and let the above construction be iterated to infinity. The black Apollonian circles (less their circumference) will ‘pack’ our triangle, in the sense that almost every point of it will eventually be covered. The remainder will be called Apollonian Gasket. Its surface measure vanishes, while its linear measure, defined as the sum of the circumeferences of the packing circles, is infinite. Thus the shape of the Apollonian Gasket lies somewhere between a line and a surface. It enters in the theory of Smectic A liquid crystals.

I don’t have a clue what ‘Smectic A liquid crystals’ are, but ‘smectic’ means ‘soaplike’, and this form reminds me distinctly of a lot of soap bubbles between other soap bubbles.

Now when I thought about doing this fractal, I remembered a post a while back on Bit-101 about Soddy Circles, which are also circles tangent to 3 circles which are tangent to each other (both inner and outer). Ryan Phelan posted an actionscript solution to this problem which I’ve borrowed to do the heavy lifting of figuring out the position and size of the inner circles. I just left out the outer circle. All I had to do was figure out how to do the recursion, which was tricky at first but turned out to have a really nice simple solution.

In the example below you can drag on the outer gray circles to change their position (and hence their size) which affects the size, position, and number of the Apollonian circles. Again, for best results, zoom in :)