Search code examples
algorithmgeometrycomputational-geometry

Is there an efficient algorithm for finding all intersections of a set of infinite lines?


There are efficient (compared to O(n2) pairwise testing) algorithms for finding all intersections in a set of line segments, like the Bentley-Ottmann algorithm. However, I want to find all intersections in a set of infinite lines. When the region of interest is something finite like a rectangle, the line-segment intersection algorithms can be applied after clipping the lines. But

  • Is there a simpler or more efficient way than just clipping the lines and applying line-segment intersection algorithms?
  • Is there an efficient algorithm for all intersections over the entire plane for a set of lines?

Solution

  • In general case (not all lines are parallel) there are O(n^2) intersections, so simple loop with intersection calculation is the best approach
    (there is no way to get n*(n-1)/2 points without calculations)

    For the case of existence a lot of parallel lines make at first grouping lines by direction and check only intersections between lines in diffferent groups