Location: Columbus, Ohio
Description: Although I have been interested in circle-packing for a few years and did physical tests exploring it earlier projects (1, 2), I had never actually worked on any packing scripts until this spring. One of my students in my Processing Matter seminar at OSU was interested in it and that got me started on helping her write a circle-packing script. It was a lot easier than I expected, or at least my version of it was. Here’s a much more sophisticated version by David Rutten.
The pseudocode of the script works like this:
Input: maximum radius of circles, number of circles to pack, boundary condition
- Find a random point within the boundary
- If any circles already exist, test if the point is within any of their boundries
- If not, find the distance between the point and the closest circle
- If the distance is greated than the maximum radius add a circle at that point with the maximum radius. This creates a new “root”
- If the distance is less than the maximum radius, add a circle at that point with the measured distance. This creates a new circle that is tangent with the closest circle. Draw a line between the new point and the centerpoint of the closest circle.
- Repeat steps 2-6 until the desired number of circles are created.
Credits: Andrew Kudless and Laura Rushfeldt