Algorithm for finding intersection of line segments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Algorithm for finding intersection of line segments

I'm writing a program on opencv. i have two line segments,each lines have two parts: point of start(x,y) and point of end(x,y). And I trying to find algorithm wich will find intersection of line with lower time and lower problem:) in case when count of lines will be equal N.

29th May 2017, 7:47 AM
Mikhailas
1 Answer
+ 1
There is a sweep line algorithm for this problem which can solve this problem in O((N+K) log N) time where N is the number of the line segments and K is the number of the intersection points. You can find the details of the algorithm in "computational geometry algorithms and applications" book. Or just search for sweepline algorithm for line segment intersection.
29th May 2017, 11:46 PM
AMR ELSAWY
AMR ELSAWY - avatar