Hello i am trying to understand the find intersections with the line sweep algorithm.
But the author of my book is a bit inconsistency with the information, i know we add the upper point of a line segments as an event, and we will add the intersection as an event. But when we first create the list of events, before we have moved the line at all, do we also add the lower point of the segment as an event? Or is it only the upper point and intersections there are events?
Hello i am trying to understand the find intersections with the line sweep algorithm.
Share
In the beginning of algorithm you should add both ends of a segment to the list of events. During sweeping when events occur you will be adding another events (corresponding intersection of segments).
In the upper point event you are adding segments to the sweep line.
In the lower point event you are removing segments from the sweep line.
In the intersection event you are changing order of segments in the sweep line.
When you are inserting, removing or changing order of sements in sweep line you should check if there is new a intersection.