1
votes

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: Line segments built on vertices of regular dodecagon

How to find coordinates of all intersections on this picture efficiently?

2

2 Answers

1
votes

The number of interior intersections is upperbounded by n choose 4 where n is the number of vertices. Unfortunately for convex polygons in general position, all of them will be distinct, so an efficient algorithm would be to enumerate 4-combinations (e.g., 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).

If you're interested in regular polygons specifically it may be possible to do better.

0
votes

If I am right, in any regular polygon, all 0-i segments intersect all j-k segments where 0<j<i and i<k<n-1 so that there are O(n³) intersections. Then you can rotate n times by 2π/n to obtain all solutions.

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.