Suppose I have n segments in general position. How can I quickly calculate for each of my n segments how many other n-1 it crosses?
I can do it naively in O (n 2 ) time. I can find all the intersections using the fairly simple Bentley-Ottmann algorithm in O ((n + k) log n) time, where k is the number of such intersections, and then aggregating the intersections I found in the heap matters.
I do not need to look for intersections; I just want to know how many there are. I donβt see how to change the scan line algorithm faster, since for each intersection it is necessary to reorder two things in the tree, and I canβt think of any other methods that do not suffer from the same problem.
I am also interested in hearing how to count the number of full intersections.
language-agnostic algorithm geometry computational-geometry
tmyklebu
source share