I have a bunch of variable-sized rectangles that I need to combine around a circle, presumably with the largest in the center.
NB. The circle does not have a fixed size - this is just the general form that I need.
This is more like the way I present lazy human packages (when the piece is in place, it remains.)
They are already ordered by the maximum of their width and height, the largest in magnitude.
Ideally - and I think this can be guaranteed by order - there would be no gaps at all.
The algorithm I'm struggling with:
for each rectangle:
if first:
place rectangle at origin
add all edges to edge list
else:
for each edge in edge list:
if edge is long enough to accomodate rectangle (length <= width or height depending on orientation):
if rectangle placed on this edge does not collide with any other edges:
calculate edge score (distance of mid-point from origin)
use edge with lowest edge score
place rectangle on edge
for each of this rectangles edges:
if edge overlaps one already in the edge list:
merge or remove edge
else:
add to edge list
remove used edge from edge list
add unused sections of this edge into edge list
, , , ( ) .
, , , (?) , .