Circle Packing Plugin
.NET
Summary: A basic 2D circle packing plugin for Rhino4
This plugin was made during the London 2007 DotNET workshop. It is a very simple circle packing algorithm which iteratively attempts to find a solution.
The command exposes a number of options, but there are no advanced features yet. The essential source code (VB.NET) is available from this wiki page as well.
This example plugin showcases some Rhino SDK basics such as opennurbs class inheritance and using Getters. It also provides a simple example of using display conduits to draw feedback geometry.
Download the CirclePacking command source (VB.NET)
Download the circle packing classes (VB.NET) :
- The PackCircle class contains the mathematics for circle bumping.
- The PackCircles class manages a list of multiple circles.
- The PackConduit class takes care of the feedback display.
The algorithm works as follows. Every circle in the array is compared with all circles that have a higher index. When two circles overlap (when the distance between A and B is less than the sum of both radii) then the A circle is moved away from B (V is the translation vector), until they are touching:
Before the collision test is performed, the entire array containing all circles is sorted from the center outwards. After every collision pass, the circles move towards the basepoint to reduce the amount of wasted space. The magnitude of this motion decreases exponentially as the algorithm progresses. This plugin comes with 4 different packing algorithms, the details of which differ slightly from the default behaviour (Fast packing) described above.
Circle packing efficiency expressed as the ratio of total circle area divided by the convex hull area. This results in an underestimate of efficiency which decreases as the number of circles increases.




