简体   繁体   English

找到相邻多边形的轮廓

[英]find the outline of adjacent polygons

I'm searching for a way to find the outline of two adjacent polygons. 我正在寻找一种方法来找到两个相邻多边形的轮廓。

The polygons are defined by a list of points ordered by occurrence in the polygon. 多边形由多边形中出现的点列表定义。 In my use case, there are no overlapping polygons, there are no gaps between the polygons, and there are no polygons with "holes". 在我的用例中,没有重叠的多边形,多边形之间没有间隙,并且没有带有“洞”的多边形。

I want to calculate the outline of the two polygons without any "holes". 我想计算两个多边形的轮廓,没有任何“洞”。 These pictures show the expected results. 这些图片显示了预期的结果。

在此输入图像描述

I know that there are a lot of libraries for clipping polygons, but for most of them the performance is not very good because they work for any kind of polygon (with holes, overlapping polygons etc.). 我知道有很多用于剪裁多边形的库,但是对于它们中的大多数而言,性能不是很好,因为它们适用于任何类型的多边形(具有孔,重叠多边形等)。 In my use case the algorithm has to work in real time for a lot of polygons (>20.000). 在我的用例中,算法必须实时处理许多多边形(> 20.000)。 How can I most efficiently calculate the outline? 我怎样才能最有效地计算轮廓?

Given 特定

no overlapping polygons, there are no gaps between the polygons and there are no polygons with "holes" 没有重叠的多边形,多边形之间没有间隙,也没有带“洞”的多边形

the following algorithm should do the trick. 以下算法应该可以解决问题。

  1. Discard duplicate line segments. 丢弃重复的线段。

  2. Compute the natural combinatorial embedding of what's left as a doubly connected edge list . 计算剩下的自然组合嵌入作为双重连接边列表 Each segment gives rise to two nodes (half edges, reverses of each other, with one endpoint of the segment being the head (respectively, the tail) and the other being the tail (respectively, the head)), and each half edge links to the next half edge with the same head in counterclockwise order. 每个区段产生两个节点(半边,彼此反转,其中一个端点是头部(分别是尾部),另一个端部是尾部(分别是头部)),每个半边连接以逆时针方向使用相同的头到下一半边缘。

  3. Extract the faces. 提取面部。 A face in the combinatorial embedding is a minimal, nonempty set of half edges such that, for each half edge e, the reverse of the next half edge from e is in the set. 组合嵌入中的是最小的非空半边集,使得对于每个半边e,与e的下一半边的反转在集合中。 The set of faces is a partition of the half edges. 该组面是半边的分区。 See the ASCII art diagram below. 请参阅下面的ASCII艺术图。

     U----V----W | | | | | | Z----Y----X 

    The infinite face is {U->Z, Z->Y, Y->X, X->W, W->V, V->U} . 无限面是{U->Z, Z->Y, Y->X, X->W, W->V, V->U} The next half edge from W->V is U->V . W->V的下一半边是U->V The reverse of the next half edge from W->V is V->U . W->V的下半边的反转是V->U The other faces are {U->V, V->Y, Y->Z, Z->U} and {V->W, W->X, X->Y, Y->V} . 其他面是{U->V, V->Y, Y->Z, Z->U}{V->W, W->X, X->Y, Y->V}

  4. Retain only the infinite faces by summing signed counterclockwise angles and testing the sign. 通过对有符号的逆时针角度求和并测试符号,仅保留无限面。 A finite face like {U->V, V->Y, Y->Z, Z->U} has negative sum {U->V, V->Y, Y->Z, Z->U}这样的有限面具有负和

     /_UVY - 180 + /_VYZ - 180 + /_YZU - 180 + /_ZUV - 180 = 4 * (90 - 180) = -360. 

    The infinite face has positive sum 无限的面孔有正面的总和

     /_UZY - 180 + /_ZYX - 180 + /_YXW - 180 + /_XWV - 180 + /_WVU - 180 + /_VUZ - 180 = 4 * (270 - 180) + 2 * (180 - 180) = 360. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM