私は数学があまり得意ではないので、数式をコードに変換するのに非常に苦労しており、既成のグーグルを見つけることができません。私はたくさんの小さな長方形を含む大きな長方形を持っています...そして私がする必要があるのは最大の空の長方形を計算することだけです。Anyonneは私を助けることができますか?
これが私が思いついたものです...言うまでもなく、それは大きな失敗です。
Rect result = new Rect();
for (Double l = 0; l < bigRect.Width; ++l)
{
for (Double t = 0; t < bigRect.Height; ++t)
{
Double h = 0;
Double w = 0;
while ((h <= bigRect.Width) && (w <= bigRect.Height))
{
Rect largestEmpty = new Rect(l, t, w, h);
if (smallRects.TrueForAll(smallRect => !smallRect.IntersectsWith(largestEmpty)) && ((largestEmpty.Height * largestEmpty.Width) > (result.Height * result.Width)))
result = largestEmpty;
else
break;
++h;
++w;
}
}
}