For my data visualisation I need to arrange various sized circles into a compact area – rectangle or circle. (See this and this example.)
In theory it is a two-dimensional-irregular-cutting-stock-problem but I would like to avoid going that way. You can find similar visualisations all over the web and I doubt they use any rigorous math.
All I need is the circles to appear to be arranged in some orderly fashion (with approximately same distance between them). There must be an easier way than cutting stock math. With some exaggeration I can even imagine how 2D physics engine could use gravity to make the circles fall into a container of desired shape.
I will be thankful for any advice.
The problem you’re trying to solve is called “circle packing”. Finding optimal packing densities in various shapes does indeed require rigorous math. However I was able to find some relatively simple opensource examples of circular packing algorithms.
http://wonderfl.net/c/fNNF
http://www.codeproject.com/Articles/42067/2D-Circle-Packing-algorithm-ported-to-C