正多边形的高效打包算法

发布于 2024-09-10 09:38:45 字数 118 浏览 2 评论 0原文

我正在寻找一种打包算法,它将正多边形减少为矩形和直角三角形。该算法应该尝试使用尽可能少的此类形状,并且应该相对容易实现(考虑到挑战的难度)。

如果可能的话,这个问题的答案应该解释建议算法中使用的一般启发法。

I'm looking for a packing algorithm which will reduce a regular polygon into rectangles and right triangles. The algorithm should attempt to use as few such shapes as possible and should be relatively easy to implement (given the difficulty of the challenge).

If possible, the answer to this question should explain the general heuristics used in the suggested algorithm.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

恬淡成诗 2024-09-17 09:38:45

我认为对于规则多边形来说,答案相当简单。

找到对称轴,并在每个顶点与其镜像之间画一条线。这将多边形分成梯形。每个梯形都可以变成一个长方形和两个直角三角形。

https:// content.screencast.com/users/Tom/folders/Jing/media/04cb9283-7fc0-4ccd-99ad-a4e056f81b23/2010-06-21_0056.png

I think the answer is fairly simple for regular polygons.

Find an axis of symmetry, and draw a line between each vertex and its mirror. This divides the polygon into trapezoids. Each trapezoid can be turned into a rectangle and two right triangles.

https://content.screencast.com/users/Tom/folders/Jing/media/04cb9283-7fc0-4ccd-99ad-a4e056f81b23/2010-06-21_0056.png

北陌 2024-09-17 09:38:45

它不是专门的矩形 + 直角三角形,但研究镶嵌多边形的一个很好的研究点是 Voronoi 图和 Delaunay 三角剖分此处此处

事实上,如果“直角三角形”足够好,这些保证可以为您进行三角测量,并且如果您确实需要的话,您总是可以将任何三角形分成两个直角三角形。或者,您可以砍掉三角形的“尖端”,以制作更多的直角三角形,并从直角三角形中制作一些矩形。

您还可以尝试剪耳,方法是径向扫动,如果您知道自己有相当规则的多边形,或者通过“剪掉最大的凸块”来实现。然后,将剩余的每个三角形分成两个以创建直角三角形。

多边形
(来源:eruciform.com

您可以尝试通过以一种方式扫掠,然后以另一种方式扫掠以形成梯形并以不同的方式分割它,可以减少中断,但是您必须进行检查以确保您的扫掠线没有与另一条线相交。你总是可以夹住耳朵,即使是一些实际上是分形的东西。

然而,这有时会产生非常细小的三角形。您可以执行启发式方法,例如“取最大的”,而不是沿着边缘连续裁剪,但这需要更多时间,接近 O(n^2)。在大多数情况下,Delaunay/Vornoi 会做得更快,并且使用更少的细三角形。

It's not specifically rectangles + right triangles, but a good research point for looking into tesselating polygons is Voronoi Diagrams and Delaunay Triangulations and here and here.

In fact, if "just right triangles" is good enough, these are guaranteed to triangulate for you, and you can always split any triangle into two right triangles, if you really need those. Or you can chop off "tips" of triangles to make more right triangles and some rectangles out of the right-triangles.

You can also try ear-clipping, either by sweeping radially, if you know you have fairly regular polygons, or by "clipping the biggest convex chunk" off. Then, split each remaining triangle into two to create right triangles.

polygon
(source: eruciform.com)

You could try to make less breaks by sweeping one way and then the other to make a trapezoid and split it differently, but you then have to do a check to make sure that your sweep-line hasn't crossed another line someplace. You can always ear-clip, even with something practically fractal.

However, this sometimes creates very slim triangles. You can perform heuristics, like "take the biggest", instead of clipping continuously along the edge, but that takes more time, approaching O(n^2). Delaunay/Vornoi will do it more quickly in most cases, with less slim triangles.

方觉久 2024-09-17 09:38:45

您可以尝试“剪出”可以容纳的最大矩形多边形,留下一些剩余物。继续在剩下的东西上重复切割矩形,直到最终得到三角形的碎片。然后,如果需要,您可以将它们分成两个直角三角形。我不知道这是否总是会产生能够为您提供最少数量的矩形和直角三角形的解决方案。

You can try "cuting out" the largest rectangle that can fit in the polygon, leaving behind some leftovers. Keep repeating the cutting out of rectangles on the leftovers, until you end up with triangular pieces. Then, you can split them into two right triangles if necessary. I do not know if this will always yield solutions that will give you the least amount rectangles and right triangles.

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