On intersecting a set of parallel line segments with a convex polygon

advertisement
On intersecting a set of parallel line segments with a convex
polygon of minimum area ∗
Asish Mukhopadhyay
Chanchal Kumar
School of Computer Science
University of Windsor, Canada
Indian Administrative Service, India
Eugene Greene
Binay Bhattacharya
School of Computer Science
University of Windsor, Canada
School of Computing Science
Simon Fraser University, Canada
Keywords: Algorithms; Computational Geometry; Geometric Optimization; Geometric Intersection
1
Introduction
Let S = {l1 , l2 , l3 , . . . , ln } be a set of n vertical line segments in the plane. Though not essential, to simplify
proofs we assume that no two li ’s are on the same vertical line. A convex polygon weakly intersects S if it
contains a point of each line segment on its boundary or interior. In this paper, we propose an O(n log n)
algorithm for the problem of finding a minimum area convex polygon that weakly intersects S.
The principal motivation behind this paper is the open problem proposed by Tamir [Tam88] at the fourth
Computational Geometry day at NYU to decide if there exists a convex polygon whose boundary intersects
a set of arbitrarily oriented line segments.
2
Prior Work
Edelsbrunner et al [EMP+ 82] proposed an O(n log n) time algorithm based on duality that computes a description of all the line transversals of a set of line segments in the plane. Goodrich and Snoeyink [GS90]
extended this result to propose an optimal O(n log n) time algorithm to decide if there exists a convex
polygon whose boundary intersects each li in S by reducing the problem to bipartite stabbing; this latter
problem is solved by dualization as in Edelsbrunner et al [EMP+ 82]. If there exists one, they show how to find
one of minimum perimeter or area in O(n2 ) time. This is a partial solution to Tamir’s open problem [Tam88].
Kelly et al [LMR] solved a simpler version of Tamir’s problem (as we do, too) by proposing an O(n log n)
algorithm that computes a minimum perimeter convex polygon which weakly intersects a set of n orthogonal
line segments. Their technique is interesting as it reduces the problem to shortest-path computation, but
quite impractical as it is based on Chazelle’s linear-time algorithm for polygon triangulation. Rappaport
[Rap95] extended this result to find a minimum perimeter convex polygon which weakly intersects a set of
n line segments in a fixed number of orientations in O(n log n) time.
Surprisingly, not much seems to be known on computing a minimum area convex polygon that weakly
intersects a planar set of line segments.
∗ This
is a completely revised version of a paper that originally appeared in the proceedings of CCCG 1993
1
3
Notations
A line segment in S with end-points p and q will be denoted by pq. The functions top(.) and bot(.) return
its upper and lower end-points.
The upper chain of the convex hull of the lower end-points of the line segments in S has the property that
bot(li ) for each i lies on or below it. If we partially order convex chains over a given range of x-values by
defining a chain to be “less than or equal” to another if at every point of the range the corresponding y-value
of the former is less than or equal to the corresponding y-value of the latter, then the upper hull of the lower
end-points is the “smallest” one in the given partial order to have the above property. To reflect this we
denote this lowest upward-convex chain by luc(S).
Similarly, the lower chain of the convex hull of the upper end-points is the “largest” among all convex chains
which have top(li ) for each i on or above it. We denote this highest downward-convex chain by hdc(S).
We assume, without loss of generality, that there is a unique leftmost line segment lL and a unique rightmost
line segment rR. Clearly, the end-points of luc(S) are L and R and those of hdc(S), l and r. Let <
u1 , u2 , ..., up > be the ordered set of vertices on luc(S) from L to R and < v1 , v2 , ..., vq > those on hdc(S)
from l to r. Let P ′ be the convex region that consists of the points lying on or below luc(S) and on or above
hdc(S) (Fig. 1).
r
l
p
q
P′
L
R
Figure 1: The core area P ′ defined by luc(S) and hdc(S)
4
Characterization
In this section we discuss our characterization of a minimum area convex polygon, P , that weakly intersects S.
Fact 1: A convex polygon that weakly intersects all the segments must contain the core area P ′ .
Proof: A convex polygon, P , that weakly intersects all the segments can be obtained by constructing the
convex hull of a set of points {p1 , p2 , p3 , . . . , pn }, where each pi is a point of li . Consider the convex region Ru formed by the upper hull of P and the rays to -∞ from the extreme vertices of P on lL and rR.
For two adjacent vertices ui and ui+1 on luc(S), the edge joining them must be contained in the convex
region under consideration as ui and ui+1 being bottom end points of their respective segments must be
on or below the upper convex chain of P and hence in Ru . Thus luc(S) must be contained in Ru . We
can similarly argue that hdc(S) must be contained in the convex region Rl formed by the lower hull of P
2
and the rays to ∞ from the extreme vertices of P on lL and rR. Thus P ′ must be contained in P = Rl ∩Ru . 2
It follows from Fact 1 that the minimum area convex polygon, P , that weakly intersects S also contains P ′ .
We make a note here regarding the uniqueness of the segments lL and rR. Say there is a set Sl of left-most
segments, all of them on the same vertical line. Consider the segment defined by the top-most bottom
endpoint, a, and the bottom-most top endpoint, b, of Sl . If a is above b then the determination of a minimum polygon is made easier. In this case, luc(S) and hdc(S) will not cross on the left side. Instead of
having a left-most segment on which we have to choose a point, we just have a segment ab that we have to
include in the minimum area stabber P by joining it to luc(S) and hdc(S). See Figure 2 for an example.
When a is below b, luc(S) and hdc(S) cross, and we can replace the entire set Sl by a new segment ab. This
modified set S ′ = (S − Sl ) ∪ {ab} is treated exactly like S in what follows, and ab will be an extreme segment.
luc(S)
hdc(S)
Figure 2: The minimum area convex polygon will consist of luc(S) joined to hdc(S) by adding edges on the
left and right
Fact 2: The rightmost vertex and the leftmost vertex of a minimum area convex polygon, P , must be
invisible with respect to luc(S) and hdc(S).
Proof: Note that the leftmost and rightmost vertices cannot be visible with respect to both luc(S) and
hdc(S), except in the degenerate case that the line segments have a common transversal. Suppose then that
the leftmost vertex p is visible to the rightmost vertex q with respect to hdc(S).
It is clear from the skew of the triangle △opq in Fig. 3, that a slight upward perturbation of the vertex p
can reduce the area of P . Hence it cannot be of minimum area.
2
Let e be an edge on luc(S) or hdc(S), with supporting line l that intersects lL or rR (see Fig. 4). We will
partition lL and rR into intervals using all such points of intersection. From a point on lL or rR, one tangent
can be drawn to luc(S) and one tangent to hdc(S). So any point on lL or rR can be associated with one point
of tangency on each of these chains. All points in a given partition interval will share their points of tangency.
Fact 3: If the extreme vertex p lies in the interior of a partition interval, then the area of P does not increase
if we move p to one of the end points of this interval.
Proof: Let the leftmost vertex p be strictly inside a partition interval. Let tu and tl be points of tangency
to luc(S) and hdc(S) from p as shown in Fig. 4.
First, assume that p is not joined to q by a straight line. If tl is to the left of the vertical line defined by
tu , then a slight downward perturbation of the vertex p decreases the area of P . If tl is to the right of the
vertical line defined by tu (as in Fig. 4), then a slight upward perturbation of p decreases the area of P .
3
r
l
P′
o
p
q
L
R
Figure 3: p and q are visible with respect to hdc(S)
r
l
A partition interval
tu
P artition point
P′
p
q
tl
L
R
Figure 4: p and q are internal points of a partition interval
Now assume that p is joined to q by a straight line (so that either p, tu , and q are collinear, or p, tl , and q
are). Let us say that p, tu , and q are collinear (see Fig. 5). Then tu will be the point of tangency from q to
luc(S). Let sl be the point of tangency from q to hdc(S). sl has to be on or to the right of tl . There are
two possibilities for the position of q:
(a) q is in the interior of a partition interval. If tl is to the left of the vertical line defined by tu , then
a slight downward perturbation of the vertex p decreases the area of P (see Fig. 5). If tl is to the right
of the vertical line defined by tu , then sl must also be to the right of it. Given the skews of tu sl and tu tl ,
a slight downward perturbation of q, followed by a slight upward perturbation of p, will decrease the area of P .
(b) q is a partition point (see Fig. 6). The edge generating q would have to be on hdc(S) (if it was on luc(S),
then p would be a partition point as well). Let us say that sl is the rightmost point on this edge. If tl is
to the left of the vertical line defined by tu , then a slight downward perturbation of the vertex p decreases
the area of P . Assume tl (and hence sl ) is to the right of the vertical line defined by tu . q cannot be the
lowest partition point on rR (if it was, then p would be a partition point, generated by the rightmost edge
on luc(S)). Let q ′ be the partition point just below q. The tangent from q ′ to luc(S) will pass through tu .
Let s′l be the leftmost point on the edge that generated q. The tangent from q ′ to hdc(S) will pass through
4
r
l
tu
p
q
P′
tl
sl
L
R
Figure 5: Case when p, q, and tu are on a straight line
s′l . s′l can not be to the left of tl , and so it must be to the right of the vertical line defined by tu . The skew of
tu s′l means that the choice q ′ would result in a smaller polygon P than would the choice of q. Given that q ′
is now the rightmost vertex of P , and given the skew of tu tl , a slight upward perturbation of p will decrease
the area of P .
2
r
l
p
tu
q
P′
tl
sl
s′
l
q′
L
R
Figure 6: Case when p, q and tu are collinear and q is a partition point
If tu tl is vertical with respect to lL then an upward or downward perturbation of p does not change the area
of P , and in this case we can always assume that p is a partition point.
Thus the extreme vertices must be partition points that are invisible with respect to the above hulls. However, this is not sufficient. In Fig. 7 below, we have an example that shows a pair of partition points that are
invisible with respect to both hulls. The polygon P cannot be of minimum area as we can reduce its area
by a small perturbation of either the leftmost vertex or the rightmost vertex. This suggests that we must
look for partition points which minimize the area locally.
The following fact provides an interesting characterization of the partition points whose choice for p and q
minimizes the area locally on the left as well as the right.
Fact 4: If p is a left partition point which is due to en edge on the upper hull, a vertical line through the
5
r
l
p
P′
q
L
R
Figure 7: p and q are partition points, but P is not of minimum area
point of tangency to the lower hull intersects this edge on the upper hull (see Fig. 8).
Proof: From the skew of tu tl with respect to lL, it is clear that a small downward perturbation of p will
increase the area of P , while from the skew of t′u tl with respect to lL, it is clear that a small upward perturbation will increase the area of P . Thus this must be a minimum area configuration.
2
r
l
t′u
tu
p
q
P′
tl
L
R
Figure 8: p and q are partition points, and P has minimum area
We can similarly characterize the rightmost vertex q.
Fact 5: A pair of partition points, one on lL and the other on rR, that minimizes the area locally on the
left and the right is unique.
Proof: Assume there is a partition point p, generated by edge e on luc(S), and with tangent point tl , on
hdc(S), in the vertical strip defined by e.
Let e′ be an edge on luc(S) to the right of e. The associated partition point p′ will have to be above p. So
the tangent point t′l will be on or to the left of tl , and hence to the left of the vertical strip defined by e′ .
Similarly, the tangent point associated with an edge e′′ to the left of e will be to the right of the vertical
strip defined by e′′ . Hence there can be no other edge on luc(S) with the same property as e. The same can
6
be said for edges e, e′ , and e′′ on hdc(S).
Now let e′ be an edge on hdc(S), associated with a tangent point t′u on luc(S) that is in the vertical strip
defined by e′ . Let e1 and e2 be the left and right endpoints of e. Let e′1 and e′2 be the left and right endpoints
of e′ . e′ can not be wholly contained by the vertical strip defined by e, since there would be no t′u above
e′ . Assume e′1 (resp. e′2 ) is to the left of e1 (resp. e2 ) (see Fig. 9). Since t′u is directly above e′ , it would
have to be on or to the left of e1 . Similarly, tl would have to be on or to the right of e′2 . It is impossible for
both of these to be true at the same time, and hence there can be no such e′ . All other cases are symmetric. 2
r
l
p
e1
e
e2
p′
e′1
e′
e′2
L
R
Figure 9: The endpoints of e′ are to the left of the corresponding endpoints of e
If we allow two segments to be on the same vertical line, then there will be at most 2 partition points on
the left segment and two partition points on the right segment that satisfy the condition in Fact 4. A pair
of points satisfying the condition in Fact 2 can be chosen in constant time.
Fact 6: Let p be the vertex found on lL, using the characterization implied by Fact 4. Let q be the vertex
found on rR. Then p is invisible to q with respect to luc(S) and hdc(S).
Proof: Let u1 be the left vertex on the edge extended to create p, and let u2 be the right vertex. Let u3 be
the point of tangency from p to the other chain. Let v1 be the right vertex on the edge extended to create
q, and let v2 be the left vertex. Let v3 be the point of tangency from q to the other chain. So, u3 is between
the vertical lines defined by u1 and u2 . Also, v3 is between the vertical lines defined by v1 and v2 (see Fig. 10).
When considering the relative positions of u1 , u2 , v1 , and v2 , there are 11 cases (6 cases in which the extended
edges are on different chains, and 5 cases in which the extended edges are on the same chain). All of these
cases can fit into one of the following:
Case 1: u2 is strictly to the left of v2 .
(a) If u2 and v2 occur on the same chain: p is invisible to q with respect to that chain, because of the section
of chain between u1 and v1 ; and p is invisible to q with respect to the other chain, because of the section of
chain between u3 and v3 .
(b) If u2 and v2 occur on different chains: p is invisible to q with respect to the chain containing u1 and u2 ,
because of the section of chain between u1 and v3 ; and p is invisible to q with respect to the chain containing
v1 and v2 , because of the section of chain between v1 and u3 .
7
r
l
u2
p
v3
u1
q
u3
v1
v2
L
R
Figure 10: Partition points that result in local minimum areas must be invisible to each other
Case 2: The extended edges are on the same chain, and u2 and v2 are the same point.
Assume the extended edges are on luc(S). Then p will be invisible to q with respect to luc(S), because
of the section of chain between u1 and v1 . Since no two segments are on the same vertical line, u3 has to
be strictly to the left of v3 . p will be invisible to q with respect to hdc(S), because of the section of chain
between u3 and v3 .
Case 3: The same edge is extended to create p and q (u2 and v1 are the same point, and u1 and v2 are the
same point).
Assume luc(S) contains the extended edge. Then p is invisible to q with respect to luc(S), because of the
section of chain between u1 and u2 . Also, u3 and v3 will have to be on hdc(S), below the line connecting p
to q. Point p will be invisible to q with respect to hdc(S), because of u3 and v3 (and any section of chain
potentially between u3 and v3 ).
Case 4: The extended edges, occurring on different chains, overlap so that: u2 is to the right of the vertical
line defined by v2 and to the left of the vertical line defined by v1 , and v2 is to the right of the vertical line
defined by u1 (see Fig. 11).
Assume luc(S) contains u1 and u2 . Since u3 is between the vertical lines defined by u1 and u2 , then u3 has
to be v2 or a point to the left of v2 . So, p is above the line defined by v1 and v2 , and is invisible to q with
respect to hdc(S). Since v3 is between the vertical lines defined by v1 and v2 , then v3 has to be u2 or a
point to the right of u2 . So, q is below the line defined by u1 and u2 , and is invisible to p with respect to luc(S).
Case 5: (a) u1 and u2 are strictly between the vertical lines defined by v1 and v2 , or (b) vice versa.
u1 and u2 will have to be on one chain, and v1 and v2 will have to be on the other. Assume luc(S) contains
u1 and u2 . This case will never occur. In (a), there are no points between v1 and v2 on hdc(S), and so no
u3 , on hdc(S), between the vertical lines defined by u1 and u2 . In (b), there are no points between u1 and
u2 on luc(S), and so no v3 , on luc(S), between the vertical lines defined by v1 and v2 .
Case 6: The extended edges are on different chains, v2 is to the left of the vertical line defined by u1 , and
v1 is to the left of the vertical line defined by u2 (see Fig. 12).
8
r
l
u2
p
v3
u1
q
u3
v1
v2
L
R
Figure 11: One case of overlapping edges
r
l
u2
u1
p
q
v1
v2
L
R
Figure 12: A case that will not arise
Assume u1 and u2 are on luc(S). Since u3 is to the right of u1 , then u3 is on hdc(S), to the right of v2 . This
means that p is below the line defined by v1 and v2 . Since v3 is to the left of v1 , then v3 is on luc(S), to
the left of u2 . Then q must be above the line defined by u1 and u2 . This is only possible if luc(S) is below
hdc(S). This means that there is a line stabbing the segments, and we are not considering this case.
Case 7: The extended edges are on the same chain, and u1 is on or to the right of v1 .
Assume the extended edges are on luc(S). Since no two segments are on the same vertical line, u3 is strictly
to the right of v3 . q would have to be below the line defined by u3 and v3 . Also, p would have to be below
the line defined by u3 and v3 . To maintain the convexity of luc(S), this is only possible if luc(S) is below
hdc(S). Again, this case results in a line stabber.
2
Putting Facts 4, 5, and 6 together we conclude that the choice of a pair of points which minimizes the area
locally on the left and the right gives the globally minimum area convex polygon P that we are looking for.
9
5
The Algorithm
The algorithm proceeds by computing luc(S) and hdc(S). We extend the edges of these two hulls to determine their intersections with lL and rR that partition these segments. We associate a triplet of labels with
each such partition point. If it is due to, say luc(S), we store the end-points of the edge that generated this
partition point as the first two labels, while the third is the label of the vertex on hdc(S) to which we can
draw a tangent from this partition point (see Fig. 13).
v5
p1 : (v2 , v1 , u4 )
q1 : (v4 , v5 , u3 )
v1
u4
p2 : (v3 , v2 , u3 )
v2
q2 : (v3 , v4 , u4 )
u3
v4
u2
v3
u1
q3 : (v2 , v3 , u4 )
u5
Figure 13: Labelling partition points generated by edges on hdc(S)
Once we have determined the partition points on lL and rR, in linear time we can find the pair that satisfies
the criterion provided by Fact 4.
The complexity of the algorithm is in O(n log n) as finding luc(S) and hdc(S) dominates the running time.
6
Conclusions
In this paper we have described an O(n log n) algorithm for finding a minimum area convex polygon that
weakly intersects a set of n vertical segments. We have implemented the algorithm and it is available at
http://cs.uwindsor.ca/~asishm (click on the link software). An obvious open problem is to extend this
to an arbitrary collection of line segments.
7
Acknowledgements
We acknowledge the contribution made by Mr Samidh Chatterjee in implementing an initial version of the
algorithm.
References
[EMP+ 82] H. Edelsbrunner, H. A. Maurer, F. P. Preparata, A. L. Rosenberg, E. Welzl, and D. Wood.
Stabbing line segments. BIT, 22:274–281, 1982.
[GS90]
M. Goodrich and J. Snoeyink. Stabbing parallel segments with a convex polygon. Computer
vision, Graphics and Image Processing, 49:152–170, 1990.
10
[LMR]
Kelly A. Lyons, Henk Meijer, and David Rappaport. Minimum polygon stabbers of isothetic
line segments. Department of Computing and Information Science, Queen’s University, Ontario,
Canada.
[Rap95]
David Rappaport. Minimum polygon transversals of line segments. Int. J. Comput. Geometry
Appl., 5(3):243–256, 1995.
[Tam88]
Arie Tamir. Improved complexity bounds for center location problems on networks by using
dynamic data structures. SIAM J. Discrete Math., 1(3):377–396, 1988.
11
Download