简体   繁体   English

如何找到建立在多边形顶点上的所有线段的交点?

[英]How to find intersections of all line segments built on polygon vertices?

Given convex polygon with known coordinates of vertices.给定具有已知顶点坐标的凸多边形。 Every pair of vertices is connected by a line segment.每对顶点都由一条线段连接。 Is there efficient algorithm to find intersections of resulting line segments?是否有有效的算法来找到结果线段的交点?

For example, with regular dodecagon all line segments form this picture:例如,对于正十二边形,所有线段都形成了这张图片: 建立在正十二边形顶点上的线段

How to find coordinates of all intersections on this picture efficiently?如何有效地找到这张图片上所有交叉点的坐标?

The number of interior intersections is upperbounded by n choose 4 where n is the number of vertices.内部交叉点的数量上限为 n 选择 4,其中 n 是顶点的数量。 Unfortunately for convex polygons in general position, all of them will be distinct, so an efficient algorithm would be to enumerate 4-combinations (eg, using this method ) and compute the one intersection that arises from each combination (if you number the vertices in clockwise order, then the intersection of the segment from the lowest to the second highest with the segment from the second lowest to the highest).不幸的是,对于一般的凸多边形 position,它们都是不同的,因此一种有效的算法是枚举 4 种组合(例如,使用此方法)并计算每个组合产生的一个交集(如果您在顺时针顺序,然后是从最低到第二高的线段与从第二低到最高的线段的交点)。

If you're interested in regular polygons specifically it may be possible to do better.如果您特别对正多边形感兴趣,可能会做得更好。

If I am right, in any regular polygon, all 0-i segments intersect all jk segments where 0<j<i and i<k<n-1 so that there are O(n³) intersections.如果我是对的,在任何正多边形中,所有0-i线段都与所有jk线段相交,其中0<j<ii<k<n-1 ,因此存在O(n³)个交点。 Then you can rotate n times by 2π/n to obtain all solutions.然后可以按2π/n旋转n次得到所有的解。

There are duplicated intersections, but I suspect (without proof) that this does not change the asymptotic behavior, and brute force is probably efficient.有重复的交叉点,但我怀疑(没有证据)这不会改变渐近行为,并且蛮力可能是有效的。 I have no idea how to avoid the duplicates.我不知道如何避免重复。

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

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