如何最小化两个子多边形的最大纵横比?

发布于 2024-11-16 16:15:16 字数 205 浏览 3 评论 0原文

我想使用直线将凸多边形切成给定面积比的两部分,以使两个子多边形的较大纵横比最小化。

目前我的方法包括选择一个随机起点,计算将多边形分割成目标区域的适当终点,然后计算两个纵横比中较大的一个。然后重复这个很多次,直到我足够接近最小值!

多边形 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

佼人 2024-11-23 16:15:16

我一直在研究的方法与 Belisarius 非常相似,所以我只会分享一些关于我的想法的注释(我正在使用 Mathematica)。

  • 可以放置切割的边对的数量是顶点数量的二次方 (1/2 n (n-1) ):(线通过连接每对的起始顶点来标记边对)

在此处输入图像描述

黄色区域标记了可以定位剪切的区域:

在此处输入图像描述

因此,在对所有组合进行大量计算之前,最好删除无效的候选者。下面显示了剩余的一些面积比:

在此处输入图像描述
- 正如贝利撒留所说,您可以找到上述每种情况的面积比范围,但简单地取最小值和最大值是不正确的。当您反转面积比中的两个区域时得到的两个范围可能是不相交的。我使用 Mathematica 的 Interval 算术来为我处理这个问题:

在此处输入图像描述

检查给定的是否面积比也可以使用舒适的间隔函数来处理:

containsRatioQ[area1_, area2_, areaBetween_, ratio_] := 
 IntervalMemberQ[areaRatioInterval[area1, area2, areaBetween], ratio]
  • 参数 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 的函数:

\[Mu] -> (-2*aL + givenAreaRatio*(2*
       aR - (p1y - p3y)*(p2x - p4x) + (p1x - p3x)*(p2y - p4y)) + (1 + 
      givenAreaRatio)*((-p1x)*p2y + p1y*(p2x - p4x) + p2y*p4x + 
      p1x*p4y - p2x*p4y)*\[Lambda])/
   ((1 + givenAreaRatio)*((-p3y)*p4x + p3x*p4y + 
     p1y*(p3x - p4x)*(-1 + \[Lambda]) - 
     p1x*(p3y - p4y)*(-1 + \[Lambda]) + ((-p2y)*p3x + p2x*p3y + 
        p2y*p4x - p2x*p4y)*\[Lambda]))

其中 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 方程所取代。现在我们只剩下一个参数

  • 这是面积比为 1 的最小化过程的结果。绿色曲线是绿色多边形的长宽比(+ 取决于 mu 的添加面积),红色曲线是红色多边形(+ 取决于 mu 的添加面积)。

在此处输入图像描述

  • 最后,这是您“最满意”的多边形切割:

在此处输入图像描述

我有一个 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 number of edge pairs in which the cut may be placed is quadratically in the number of vertices (1/2 n (n-1) ): (lines mark edge pairs, by connecting the starting vertices of each pair)

enter image description here

The yellow areas mark the area were one could locate the cut:

enter image description here

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:

enter image description here
- 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:

enter image description here

Checking whether a given area ratio is also handled with a comfortable Interval function:

containsRatioQ[area1_, area2_, areaBetween_, ratio_] := 
 IntervalMemberQ[areaRatioInterval[area1, area2, areaBetween], ratio]
  • 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:

\[Mu] -> (-2*aL + givenAreaRatio*(2*
       aR - (p1y - p3y)*(p2x - p4x) + (p1x - p3x)*(p2y - p4y)) + (1 + 
      givenAreaRatio)*((-p1x)*p2y + p1y*(p2x - p4x) + p2y*p4x + 
      p1x*p4y - p2x*p4y)*\[Lambda])/
   ((1 + givenAreaRatio)*((-p3y)*p4x + p3x*p4y + 
     p1y*(p3x - p4x)*(-1 + \[Lambda]) - 
     p1x*(p3y - p4y)*(-1 + \[Lambda]) + ((-p2y)*p3x + p2x*p3y + 
        p2y*p4x - p2x*p4y)*\[Lambda]))

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

  • Here is the result for the minimization procedure for an area ratio of 1. The green curve is the aspect ratio for the green polygon (+ added area depending on mu) and the red curve is the aspect ratio for the red polygon (+ added area depending on mu).

enter image description here

  • And here, finally, is your 'most pleasing' polygon cut:

enter image description here

I have a Mathematica notebook that I will send on request. Just send me an e-mail.

对你而言 2024-11-23 16:15:16

我会先写下一个粗略的答案,如果您有兴趣沿着这些思路进行下去,我可能会扩展它。我有一个程序在 Mathematica 中运行来计算这个(有一些限制),如果我有时间完成它,我也会发布它。

该问题实际上有两个部分:

  • 找到产生所需面积比的多边形分区
  • 从它们中选择使纵横比最小化的多边形分区

让我们先看第一个问题。您可以这样做:

考虑每一对边,如下图所示

在此处输入图像描述

对于每一对,考虑以下三个区域:

在此处输入图像描述

因此,您可以使用以下方法分割多边形时获得的最大和最小比率穿过这两条边的线是以下集合的 Min()Max[]

 { (S1+S2)/S3, S3/(S1+S2), (S2+S3)/S1, S1/(S2+S3) }

如果您所需的比率不在该集合的 Max 和 Min 之间,则丢弃该对。

注意:要计算面积,您可以使用此公式

一旦获得所有候选边对,问题就是找到一个仅包含一个参数的函数,该函数描述符合所需比率的四边形的所有可能分区。

如果你用等式对两边进行参数化,

{x, y} = {A} + t {B- A} 

你将能够得到这样的结果:

在此处输入图像描述

你可以根据两个参数(每边一个),使用相同的公式计算绿色面积。我上传到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:

  • Find the polygon partitions which yields your desired area ratio
  • Select from them the one that minimizes the aspect ratio

Let's see the first problem first. You could do something like:

Consider each pair of sides, like in the following figure

enter image description here

And for each pair, consider the three following areas:

enter image description here

So, the maximal and minimal ratios that you may get for partitioning the polygon with a line crossing these two sides are the Min() and Max[] of the following set:

 { (S1+S2)/S3, S3/(S1+S2), (S2+S3)/S1, S1/(S2+S3) }

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

{x, y} = {A} + t {B- A} 

you will be able to get something like this:

enter image description here

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:

enter image description here

And the aspect ratio plot for each area is:

enter image description here

Where each unit in the x axis corresponds to one side.

Let me know if you want more details ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文