简单的2D多边形三角

编程入门 行业动态 更新时间:2024-10-28 02:27:46
本文介绍了简单的2D多边形三角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

试图三角一套的简单的2D多边形,我想出这个算法:

Trying to triangulate a set of simple 2d polygons, I've come up with this algorithm:

  • 1)为在该多边形的每个顶点,计算两个相连边缘间的角度
  • 2)分类顶点通过减少相对角,以该多边形的内部
  • 3)如果少于3个顶点的集合,我们就大功告成了
  • 4)采取由它和它的两个邻国形成了集和输出三角形的最后一个顶点
  • 5)从集合中删除顶点
  • 6)更新两个邻国的角度
  • 7)跳转到2

我测试过它,并发现它的工作即使在真正的大而复杂的简单的2D多边形(它没有为多边形孔或自相交的多边形工作)。

I've tested it, and found it to work even on really big and complicated simple 2d polygon (it don't work for polygon with a hole or self intersecting polygons).

有没有其他的情况会产生退化的结果呢?

Is there corner cases that will produce degenerate result?

请问这个算法是一个已知的?

Does this algorithm is a known one?

如果没有,我想,以确保该算法是坚如磐石,但我没有数学背景来证明这一点。

If not, I would like to be sure this algorithm is rock solid but I have not the mathematical background to prove it.

多谢了。

推荐答案

您正在做一个版的耳朵削波的方式进行三角测量,请参阅:的 en.wikipedia/wiki/Polygon_triangulation

You are doing a version of "ear clipping" approach to triangulation, see: en.wikipedia/wiki/Polygon_triangulation

如果另一多边形顶点(比如从多边形的另一侧)结束了三角形的耳朵你形成在你的算法失败。考虑这个例子:

Your algorithm fails if another polygon vertex (say from the other side of the polygon) ends up inside the triangle 'ear' you form. Consider this example:

您的算法将选择的第一,并与这两个相邻的边缘(用虚线连接的)一个三角形。但这个三角形包括另一个顶点(B)和显然是不正确。

Your algorithm will choose A first, and make a triangle with the two adjacent edges (connected with the dashed line). But this triangle includes another vertex (B) and is clearly incorrect.

广义耳裁剪方法取决于找到的耳朵,你可以剪掉不具有任何包括顶点。

The generalized ear clipping approach depends on finding ears you can clip off that do not have any included vertices.

更多推荐

简单的2D多边形三角

本文发布于:2023-08-01 22:16:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1272217.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多边形   简单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!