CirclePacking
Reproducing a circle packing algorithm.
Install / Use
/learn @amanitta/CirclePackingREADME
Circle Packing
Reproducing the simplest version of the circle packing algorithm proposed in this article by Collins and Stephenson.</br></br> The /src folder contains the implementation of the algorithm written in C++ (the correspondent executables are located in /bin).</br></br> In order to have a circle packing, we need to start with a complex K. In cpack_test.cc the structure of such complex is hard-coded in the program.</br> With the help of cpack.py we can visualize an animation showing the creation of the circle packing as the algorithm progresses.<br> The program should be run like this:
./bin/cpack_test | python ./src/cpack.py
<p align="center">
<img src="https://github.com/amanitta/circlePacking/blob/master/cpack_01.gif"/>
</p>
It is possible to choose between fixed (default) and random boundary conditions using the options -f and -r in the executable.</br></br>
The other python script (pointsForComplex.py) provides instead with a way to create a complex with a certain number of boundary and interior points. The geometrical form of the complex is not important at all: the only thing which is relevant is knowing the neighbouring nodes to which each interior vertex is connected. The script thus places the boundary points equally spaced on a circle, while the interior points are chosen at random inside the circle itself. A Delaunay triangulation is exploited to link the vertices inside the circle. The output of the script consists of the list of neighbours for each internal vertex, sorted in clockwise order.</br> The program should be run like this
python pointsForComplex.py BOUNDARY INTERIOR [SEED]
<p align="center">
<img src="https://github.com/amanitta/circlePacking/blob/master/complex.jpg">
</p>
The output of the python script just mentioned can then be fed to cpack_final, which reads the structure of the complex created and runs the circle packing algorithm.</br> cpack_debug.py is extremely useful for debugging the program and understanding how the animation is created. It can also be used to show the final result of the run, as shown below.
python ./src/pointsForComplex.py 9 8 30 | ./bin/cpack_final | python ./src/cpack_debug.py
<p align="center">
<img src="https://github.com/amanitta/circlePacking/blob/master/cpack_debug.jpg">
</p>
Just as before, we can then produce an animation showing the action of the packing algorithm, now with an input (the complex) that has not to be hard-coded anywhere.
python ./src/pointsForComplex.py 20 25 987 | ./bin/cpack_final | python ./src/cpack.py
Complex | Circle Packing :-------------------------:|:-------------------------: <img src="https://github.com/amanitta/circlePacking/blob/master/complex_final.jpg"/> | <img src="https://github.com/amanitta/circlePacking/blob/master/cpack_final.gif"/>
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
104.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
345.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
