如何最小化两个子多边形的最大纵横比?
我想使用直线将凸多边形切成给定面积比的两部分,以使两个子多边形的较大纵横比最小化。
目前我的方法包括选择一个随机起点,计算将多边形分割成目标区域的适当终点,然后计算两个纵横比中较大的一个。然后重复这个很多次,直到我足够接近最小值!
多边形 A 的长宽比定义为:
asp(A) := diam(A)^2 / area(A)
I'd like to cut a convex polygon into two with a given ratio of areas using a straight line, such that the larger aspect ratio of the two subpolygons is minimised.
My approach at the moment involves choosing a random starting point, computing the appropriate end point that splits the polygon into the target areas, then calculating the larger of the two aspect ratios. Then repeating this lots of times until I'm close enough to a minimum!
The aspect ratio of a polygon A is defined as:
asp(A) := diam(A)^2 / area(A)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在研究的方法与 Belisarius 非常相似,所以我只会分享一些关于我的想法的注释(我正在使用 Mathematica)。
黄色区域标记了可以定位剪切的区域:
因此,在对所有组合进行大量计算之前,最好删除无效的候选者。下面显示了剩余的一些面积比:
- 正如贝利撒留所说,您可以找到上述每种情况的面积比范围,但简单地取最小值和最大值是不正确的。当您反转面积比中的两个区域时得到的两个范围可能是不相交的。我使用 Mathematica 的
Interval
算术来为我处理这个问题:检查给定的是否面积比也可以使用舒适的间隔函数来处理:
参数 Labda 的值,该参数确定通过第一条边的切割位置,作为 mu 的函数(确定第二条边的位置的参数)
<代码>\[Lambda] -> (2*aL + 给定面积比*(-2*
aR + (p1y - p3y)*(p2x - p4x) - (p1x - p3x)*(p2y - p4y)) + (1 +
给定面积比)*(p1x*p3y - p3y*p4x + p1y*(-p3x + p4x) -
p1x*p4y + p3x*p4y)*\[Mu])/
((1 + 给定面积比)*((-p2x)*p4y +
p1x*(-p2y + p4y) + (p1x - p2x)*(p3y - p4y)*\[Mu] +
p1y*(p2x + p4x*(-1 + \[Mu]) - p3x*\[Mu]) +
p2y*(p4x + p3x*\[Mu] - p4x*\[Mu])))
或 mu 作为 labda 的函数:
其中 p1、p2、p3、p4 是包含切口的区域的坐标, aL 是“绿色”多边形的面积,aR 是“红色”多边形的面积(参见本文底部的图)。
并非一条边上的每个点总是在另一条边上给出解决方案,反之亦然。我检查 lambda 方程,找到将 lambda 设置为 0 或 1 的 mu 值,反之亦然。
作为最后一步,我最小化两个区域的纵横比函数的最大值。在 Mathematica 语言中:
NMinimize[{Max[aspectRatio[area1tot],aspectRatio[area2tot]],\[Mu]范围[[1]] <= \[Mu] <= \[Mu]范围[[2 ]]}, \[Mu]]
其中are1tot和area2tot是由mu和lambda参数化的两半的总面积,其中lambda被上述以 mu 表示的 lambda 方程所取代。现在我们只剩下一个参数
我有一个 Mathematica 笔记本,我将根据要求发送。只需给我发一封电子邮件即可。
The method I've been working on is very similar to Belisarius, so I'll only share a few notes about my thinking (I'm using Mathematica).
The yellow areas mark the area were one could locate the cut:
so before doing many calculations on all combinations it's good to mow away invalid candidates. Here is shown for some area ratios what pairs are left:
- As belisarius says you can find the range of area ratios for each of the above situations, but simply taking the Min and Max is incorrect. The two ranges you get when you reverse the two areas in your area ratio maybe disjunct. I use Mathematica's
Interval
arithmetic to handle this for me:Checking whether a given area ratio is also handled with a comfortable Interval function:
The value of the paramater labda that determines the location of the cut through the first edge as a function of mu (the parameter that determined the position for the second edge)
\[Lambda] -> (2*aL + givenAreaRatio*(-2*
aR + (p1y - p3y)*(p2x - p4x) - (p1x - p3x)*(p2y - p4y)) + (1 +
givenAreaRatio)*(p1x*p3y - p3y*p4x + p1y*(-p3x + p4x) -
p1x*p4y + p3x*p4y)*\[Mu])/
((1 + givenAreaRatio)*((-p2x)*p4y +
p1x*(-p2y + p4y) + (p1x - p2x)*(p3y - p4y)*\[Mu] +
p1y*(p2x + p4x*(-1 + \[Mu]) - p3x*\[Mu]) +
p2y*(p4x + p3x*\[Mu] - p4x*\[Mu])))
or mu as a function of labda:
with p1, p2, p3, p4 the coordinates of the area embracing the cut and aL the area of the 'green' polygon and aR the area of the 'red' polygon (see figure at the bottom of this post).
Not every point on one edge always gives a solution on the other edge and vice versa. I check the equation for lambda to find values of mu which set lambda at 0 or 1, and vice versa.
As a last step I minimize the maximum value of the aspect ratio functions of the two areas. In Mathematica language:
NMinimize[{Max[aspectRatio[area1tot], aspectRatio[area2tot]], \[Mu]range[[1]] <= \[Mu] <= \[Mu]range[[2]]}, \[Mu]]
with are1tot and area2tot being the total areas for both halves parametrized by mu and lambda and where lambda is replaced by the above equestion for lambda in terms of mu. Now we have only one parameter left
I have a Mathematica notebook that I will send on request. Just send me an e-mail.
我会先写下一个粗略的答案,如果您有兴趣沿着这些思路进行下去,我可能会扩展它。我有一个程序在 Mathematica 中运行来计算这个(有一些限制),如果我有时间完成它,我也会发布它。
该问题实际上有两个部分:
让我们先看第一个问题。您可以这样做:
考虑每一对边,如下图所示
对于每一对,考虑以下三个区域:
因此,您可以使用以下方法分割多边形时获得的最大和最小比率穿过这两条边的线是以下集合的
Min()
和Max[]
:如果您所需的比率不在该集合的 Max 和 Min 之间,则丢弃该对。
注意:要计算面积,您可以使用此公式
一旦获得所有候选边对,问题就是找到一个仅包含一个参数的函数,该函数描述符合所需比率的四边形的所有可能分区。
如果你用等式对两边进行参数化,
你将能够得到这样的结果:
你可以根据两个参数(每边一个),使用相同的公式计算绿色面积。我上传到ideone,只是因为太笨拙,无法在这里
发布第一步是将问题减少到只有一个参数。这样做是考虑到您希望完整的多边形具有一定的面积比。
从这两个方程中,您可以得到每对边的两个参数之间的关系(双曲线)。所有这些切口都具有所需的面积比。
接下来是计算纵横比,并选择最小值。由于功能非常流畅,您只需编写一个极限查找器即可。
在这里,您可以看到六边形的纵横比结果,将一个顶点作为分割点,如下所示:
每个区域的纵横比图为:
其中 x 轴中的每个单位对应于一个边。
如果您想了解更多详细信息,请告诉我...
I'll write down a sketched answer first, and probably expand it if you are interested in going along these lines. I've a program running to compute this in Mathematica, (with some restrictions), and I'll also post it if I get some time to finish it.
The problem has actually two parts:
Let's see the first problem first. You could do something like:
Consider each pair of sides, like in the following figure
And for each pair, consider the three following areas:
So, the maximal and minimal ratios that you may get for partitioning the polygon with a line crossing these two sides are the
Min()
andMax[]
of the following set:If your desired ratio is not between the Max and Min of this set, discard the pair.
NB: For calculating areas you may use this formula
Once you get all the candidate pair of sides, the problem is to find a function of only one parameter that describes all possible partitions of the quadrilateral that respects the desired ratio.
If you parametrize both sides with an equation like
you will be able to get something like this:
And you can find the green area using the same formula, depending upon the two parameters (one for each side). I uploaded it to ideone, just because it is too clumsy to post here
The next step is reducing the problem to only one parameter. This is done taking into account that you desire a certain area ratio for your complete polygon.
From that two equations you get a relationship (an hyperbola) between both parameters for each pair of sides. All those cuts have the desired area ratio.
Next thing is calculating the aspect ratio, and selecting the minimum. As the functions are pretty smooth, all you need to do is to program an extreme finder.
here you can see the results for the aspect ratio for an hexagon, taking one vertex as a split point like this:
And the aspect ratio plot for each area is:
Where each unit in the x axis corresponds to one side.
Let me know if you want more details ...