1

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?

Alexander Anishin
  • 106
  • 1
  • 1
  • 5

2 Answers2

1

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.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • Any ideas for algorithm optimisation for regular polygons? – Alexander Anishin Sep 20 '20 at 12:38
  • @AlexanderAnishin http://www-math.mit.edu/~poonen/papers/ngon.pdf gives a formula for the number of intersections but more interestingly cites the fact that, other than the center, at most 7 lines will meet in the center. Unfortunately this means you're stuck with a Theta(n^4) algorithm, so it probably doesn't make sense to try to analyze the coincident intersections in detail. – David Eisenstat Sep 20 '20 at 12:47
  • @DavidEisenstat: "stuck" with a Θ(n^4) algorithm is not a problem as long as this corresponds to the effective number of intersections. –  Sep 20 '20 at 13:48
0

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.