Stabbing Line Segment
Stabbing Line Segment
Stabbing Line Segment
Abstract.
An algorithm for the geometric problem of determining a line (called a stabbing line) which
intersects each of n given line segments in the plane is presented. As a matter of fact, the algorithm
computes a description of all stabbing lines. A purely geometric fact is proved which infers that this
description requires O(n) space to be .specified. Our algorithm computes it in O(n log n) time which
is optimal in the worst case.
Using the description of the stabbing lines, we are able to decide in O(Iog n) time whether or not
a specified line is a stabbing line. Finally, the problem of maintaining the description of all stabbing
lines while inserting and deleting line segments is addressed.
1. Introduction.
In the last few years, a flurry of activity can be observed in the design of
algorithms for geometric problems. We interpret this as being caused by the
growing interest in the manipulation of graphical data (e.g. in computer
graphics, architectural design, geography, etc.) and also caused by the fact that
human intuition is often helped by using a geometric setting for practical
problems (e.g. in database organization, VLSI design, etc.). The geometric
scenario favors the design of more efficient solutions as well as their transparent
presentation.
This paper investigates a geometric problem that is closely related to
reachability and visibility questions in the plane. Lee 1-6] and Lee, Preparata 17]
studied the problem of finding optimal tours which avoid certain obstacles.
Edelsbrunner, Overmars, and Wood [3] examined several facets of the generalized
hidden line problem in the plane. Both types of problems are closely related
since tours as well as visual rays have to avoid obstacles.
Beside this relationship to issues of obvious practical interest, the problem
we are dealing with is of interest in its own right: Given a set of (potentially
intersecting) line segments in the plane, determine a line, called a stabbing line,
which intersects each segment in the set. In the visibility environment this
problem may be interpreted as: find a direction from which one can look through
a set of doors, where a door is an interval on an arbitrarily directed line.
Astonishingly, there seems to be no trivial brute-force method for this
problem. As far as the authors know, the first algorithm that solves the
problem is an application of a very general method due to Edelsbrunner,
Overmars, and Wood [3]. However, due to its generality, their algorithm lacks
a great deal of efficiency, i.e. it requires O(n 2 tog n) time to find a stabbing line
for n line segments.
Our tailor-made algorithm not only improves the time requirements to
O(n Iogn); it also computes a description of all stabbing lines. From this
description one can derive in constant time, a specific stabbing line (provided
one exists). Furthermore, this description is well suited for supporting a related
searching problem, i.e. determine for specified query lines whether they are
stabbing lines or not.
The organization of the paper is as follows. Section 2 provides the geometric
preliminaries needed for the algorithm presented in Section 3. The related
searching problem in a static and dynamic environment is briefly discussed in
Section 3, Finally, Section 4 reviews our results and gives some open problems.
2. Geometric preliminaries.
This section provides the geometric tools and facts needed for the design
and analysis of our algorithm which computes a description of all stabbing lines.
At the base of our algorithm lies a geometric transform which is reviewed below.
A more detailed discussion is found in Brown [1]. Furthermore, nontrivial
properties about the intersection of so-called double wedges are presented.
The geometric transform, which we call T, maps a point into a line and a line
into a point.
T: p = ( a , b ) ~ Tp: y = a x + b ,
A line segment s is fully determined by its two endpoints. The two endpoints
are transformed into two lines which determine four wedges. Then s is trans-
formed into the two opposed wedges whose union does not contain a vertical
line in its interior, see Figure 2.1.
j
Fig. 2.1. A line segment and its transform under 7".
We call these two wedges the double wedge corresponding to a line segment.
A vertical line segment (a special case) is mapped into the area between the two
parallel lines corresponding to the endpoints.
FACT 2.2. A line l intersects a line segment s if and only if the point T~lies in the
double wedge T, of s.
FACT 2.3. The stabbing lines for a set of line segments stand in one-to-one
correspondence with the intersection points of their double wedges, see
Figure 2.2.
Hence, the intersection of the double wedges, which we call the stabbin 9
reoion, serves as a description of all stabbing lines.
Note that the segments may allow only vertical stabbing lines. In this case,
the associated stabbing region consists solely of singular points at infinity.
This can be handled by treating either the vertical stabbing lines separately or
the infinite parts of the stabbing region very carefully. Either approach can be
followed without affecting the asymptotic complexity of our algorithm.
We now consider relevant properties about the stabbing region for n line
segments. Subsequently, Section 3 focusses on the computation of the stabbing
region.
PROOF: Note first that the two wedges of a double wedge may be separated
by the vertical line through the intersection point of the two lines determining
the double wedge. This fact immediately implies that the orthogonal projections
onto the x-axis do not properly intersect and that the stabbing region consists of
at most n + 1 polygons. Since each polygon is the intersection of convex wedges,
it is also convex. I
THEOREM 2.5: The number of edyes bordering the stabbing region for n line
seyments in the plane is bounded by O(n).
PROOF: Let w denote an arbitrary double wedge determined by two lines inter-
secting at a point p. Then w is bordered by four half-rays emanating from p which
we term w's upper right ray (i.e. the half-ray on the line with the greater slope
leaving p to the right), upper left ray, lower left ray, and lower right ray.
Let S denote the stabbing region for n line segments consisting of m polygons
P1, P2 . . . . . P,,, such that P~ lies to the left of P~ provided i is smaller than j.
We classify the edges of each polygon by the kind of half-ray supporting them.
We prove that each class of half-rays is associated with at most 2n + 1 edges.
Without loss of generality consider edges associated with upper right rays only.
Assign to each polygon P~, for i = 1. . . . . m, the list of upper right rays which
determine the bordering edges of P,. Obviously, only the upper right ray with
minimal slope in the list for polygon P~ can also determine a bordering edge for
a polygon P~, for j greater than i. Now, remove the upper right rays with
278
minimal slope from the m (potentially empty) lists. Each upper right ray occurs
at most once in these reduced lists. Consequently, the original lists collectively
contain at most n half-rays with non-minimal slope and at most m half-rays
with minimal slope, respectively.
As m is no more than n + 1 and the same argument holds for the remaining 3
types of half-rays, we conclude that 8n + 4 is an upper bound for the number
of edges, m j
Clearly, 8n + 4 edges is not the tightest p6ssible upper bound. We conjecture
that it can be improved considerably as our best example gives rise to 6 n - 2
edges.
Let us briefly restate the problem. Given a set S of n line segments in the
plane, compute all stabbing lines, i.e. the lines which intersect all segments.
The algorithm does this by determining the stabbing region for the segments.
It uses the divide-and-conquer heuristic and the plane sweep technique for the
merge step.
CASE 1. If there is only one line segment in the set S, the stabbing region is
the double wedge of this segment.
CASE 2. Otherwise (i.e. if there are at least two segments) divide the set S into
two equal size subsets, and compute the stabbing region of both subsets
recursively. Compute the stabbing region of the whole set by intersecting the
stabbing regions of the subsets.
LEMMA 3.1 : The intersection of two stabbing regions for nl and n 2 segments can
be computed in O(n 1 +n2) time.
STABBING LINE SEGMENTS 279
PROOF. Recall that the stabbing region for n segments consists of at most n + 1
convex polygons whose orthogonal projections onto the x-axis do not intersect
except potentially at their endpoints (Lemma 2.4).
The intersection of two stabbing regions for n 1 and n 2 segments is computed by
the application of the plane-sweep technique. A stabbing region is represented
by the list of vertices sorted with respect to the x-coordinate. Additionally,
each vertex is associated with the two (or potentially four) adjacent vertices of
the (potentially two) polygons it belongs to.
A vertical line sweeping from left to right intersects at most one polygon of
a stabbing region at a time. Consequently, it intersects at most four edges of
both stabbing regions, so all required computations can be accomplished in
constant time. Some care has to be taken in the efficient handling of the inter-
sections which occur. Note that at each position of the sweeping line there are
at most four anticipated intersections, which can be treated in constant time
each. •
THOREM 3.2: The stabbing region Jbr n line segments in the plane can be com-
puted in O(n log n) time.
PROOF: The assertion follows directly from Lemma 3.1 and our divide-and-
conquer strategy: the time T(n) required by our algorithm is 2T(n/2) to solve
the two subproblems of size n/2, plus O(n) to combine these solutions into a
solution for the entire problem. Hence, T(n) = 2T(n/2)+ O(n) = O(n log n). m
THEOREM3.3: There exists a data structure for n line segments in the plane that
requires O(n) space and O(n log n) time for construction which enables a query
of the form: is a given line a stabbing line or not, to be answered in O(log n) time.
projections onto the x-axis do not properly intersect. Due to Theorems 2.5
and 3.2, the polygons require O(n) space and O(n log n) time for construction.
Furthermore, a query can be answered in O(log n) time by using binary
search. •
THEOREM3.4: The stabbing region for a set of n line segments can be maintained
with O(n loglog n) space and a penalty of O(n) time per insertion and deletion.
PROOF. Due to Lemma 3.1, the intersection of the two stabbing regions for
sets A and B of line segments (that is the stabbing region for the union of A and B)
can be found in linear time. The assertion is a consequence of this fact and a
very general method for dynamizing similar structures due to Overmars [8]
and Gowda, Kirkpatrick [5]. •
4. Discussion.
s~gments that can be intersected by a single line, (ii) to find a line that does
not intersect a single segment and separates the set into two nonempty subsets,
(iii) to determine a direction such that the shadows of the segments do not
intersect, and (iv) to determine a direction such that the view of the segments is
connected. However, the O(n 2 log n) time requirements beg for more efficient
solutions.
The generalizations of the stabbing problem and the open problems above
to three and higher dimensions are also of interest. For example investigate
the problem of finding a plane that intersects each of a given set of line segments
in three dimensions.
REFERENCES