python graphics program to create an Apollonian Gasket

Just for fun I wanted to write a program to create images like these:

gasket

The links below probably have everything you need to do this, but it took me a while to get it all working. Here's my algorithm, borrowing some from all of those links.

Draw one large circle (C1)
Pick a random point inside C1 and draw second circle (C2)
  (Use distance from random point to C1 center to get correct radius for C2)
Create and draw 3rd circle (C3) such that it is tangent to C1 and C2
  (center of C3 is on opposite side of C1 center from C2)
	(2*r1 = 2*r2 + 2*r3, so r3 = r1 - r2 = dist)

	(theta = math.atan((y2-y1)/float(x1-x2)))
	(x3 = r1*math.cos(theta) + x2)
	(y3 = y2 - r1*math.sin(theta))
gasket radii

Notes

  1. You might need to hit ENTER a few times to get the login prompt.
  2. I used to have a cyclades console server

Useful links


back to helps
Last Modified: Mon 27 Jan 2014 03:28:21 PM EST