Bentley–Ottmann algorithm: Difference between revisions

Content deleted Content added
No, little o was correct — to replace it by an absolute inequality you need to know more than is stated here about the constant factors in the runtime of the algorithms.
Overall strategy: Edited for clarity & accesibility
Line 4:
 
==Overall strategy==
The main idea of the Bentley–Ottmann algorithm is to use a [[sweep line algorithm|sweep line]] approach, in which a vertical line ''L'' moves from left to right across the plane, intersecting the input line segments in sequence as it moves.<ref>In the description of the algorithm in {{harvtxt|de Berg|van Kreveld|Overmars|Schwarzkopf|2000}}, the sweep line is horizontal and moves vertically; this change entails swapping the use of ''x''- and ''y''-coordinates consistently throughout the algorithm, but is not otherwise of great significance for the description or analysis of the algorithm.</ref> It is simplest to describe theThe algorithm foris thedescribed casemost that the input iseasily in [[general position]], meaning, thatin nothis case, that:<ol><li>No two line segment endpoints or crossings have the same ''x''-coordinate,</li><li>No noline segment endpoint lies onupon another line segment, and no</li><li>No three line segments crossintersect at thea samesingle point.</li></ol> In thissuch a case, ''L'' will always intersect the input line segments in a set of points whose vertical ordering changes only at a finite set of discrete ''events''. Thus, the continuous motion of ''L'' can be broken down into a finite sequence of steps, and simulated by an algorithm that runs in a finite amount of time.
 
There are two types of event that may happen during the course of this simulation. When ''L'' sweeps across an endpoint of a line segment ''s'', the intersection of ''L'' with ''s'' is added to or removed from the vertically ordered set of intersection points. These events are easy to predict, as the endpoints are known already from the input to the algorithm. The remaining events occur when ''L'' sweeps across a crossing between two line segments ''s'' and ''t''. These events may also be predicted from the fact that, just prior to the event, the points of intersection of ''L'' with ''s'' and ''t'' are adjacent in the vertical ordering of the intersection points.