おそらく最大のものを中心にして、大まかに円に合わせる必要がある可変サイズの長方形がたくさんあります。
注意。円は固定サイズではありません - それは私が求めている全体的な形です.
これは、怠惰な人間のパックを想像する方法に似ています (ピースが配置されると、それは残ります)。
それらは、幅と高さの最大値から順に並べられています。
理想的には、これは注文によって保証できると思いますが、ギャップはまったくありません。
私が苦労しているアルゴリズムは次のとおりです。
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
これは最初のいくつかの長方形では問題なく機能しますが、エッジのマージはかなり複雑で、使用するエッジのセクション (一方の端または他方の端) を選択する現在の方法では、多くのギャップが残る傾向があります。
最終的にはこの方法がかなり満足のいくものになると思いますが、もっと洗練された (グラフ?) アルゴリズムが欠けているように感じます。