Rectilinear convex hull with minimum area

Rectilinear convex hull with minimum area
Carlos Alegrı́a-Galicia3 , Tzolkin Garduño3 , Areli Rosas-Navarrete3 ,
Carlos Seara2 , and Jorge Urrutia1
1
Universidad Nacional Autónoma de México, Instituto de Matemáticas?
2
Universitat Politècnica de Catalunya??
3
Universidad Nacional Autónoma de México, Posgrado en Ciencia e
Ingenierı́a de la Computación
{alegria c,garduno t,areli}@uxmcc2.iimas.unam.mx,
[email protected],[email protected]
Abstract. Let P be a set of n points in the plane. We solve the problem
of computing an orientation of the plane for which the rectilinear convex
hull of P has minimum area in optimal Θ(n log n) time and O(n) space.
Keywords: rectilinear convex hull, ortho-convexity, optimization
1
Introduction
The interest in the rectilinear convex hull of planar point sets arises from the
study of the ortho-convexity [15], also known in the literature as rectilinear, x-y,
or orthogonal convexity. This non-traditional notion of convexity has been widely
studied since its formalization in the early eighties, and has found applications
in theoretical research fields such as polyhedra reconstruction [4] and fixed point
theory [9], as well as in the study of practical problems such as digital image
shape analysis [5] and VLSI circuit layout design [16]. See also [7, 8, 11].
A set S ⊂ R2 is said to be ortho-convex if the intersection of S with every
horizontal or vertical line is connected, i.e, it is empty, a point, or a single interval. Unlike ordinary convex sets, an orthogonally convex set is not necessarily
connected. The orthogonal convex hull of a set S is the intersection of all connected orthogonally convex supersets of S. So every convex set is orthogonally
convex but not vice versa. For the same reason, the orthogonal convex hull itself
is a subset of the convex hull of the same point set. A point p belongs to the orthogonal convex hull of S if and only if each of the closed axis-aligned quadrants
having p as apex has a nonempty intersection with S. The orthogonal convex
hull is also known as the rectilinear convex hull, or the x-y convex hull. As it
is easy to see, an ortho-convex set might be non-convex or disconnected. The
latter property hinders the definition of an ortho-convex closure that resembles
?
??
Partially supported by projects MTM2006-03909 (Spain), and SEP-CONACYT of
México, Proyecto 80268
Supported by MTM2009-07242, Gen Cat DGR2009GR1040, and ESF EUROCORES
programme EuroGIGA-ComPoSe IP04-MICINN Project EUI-EURC-2011-4306
2
Rectilinear convex hull with minimum area
the properties of the traditional convex hull and as a consequence, several definitions have been presented by different authors [13]. Throughout this paper,
we will use the maximal ortho-convex, or mr-convex hull stated by Ottmann et
al. [13] (see also Matousěk et al. [12]), which is defined as follows.
An orthogonal wedge is the intersection of two open half-planes whose supporting lines are orthogonal. Let Xθ and Yθ denote the X and Y coordinate axes
rotated counter-clockwise by θ degrees, respectively. We call θ-orientation to the
coordinate system formed by Xθ and Yθ . An orthogonal θ-wedge is an orthogonal
wedge whose supporting lines are parallel to the axes of the first quadrant of the
θ-orientation of the plane.
Let P ⊂ R2 denote a set of n points in general position i.e., no three collinear
points in P . An orthogonal θ-wedge is called P -free if it does not contain points
of P . Let Wθ (P ) be the set of all P -free orthogonal θ-wedges, and let
Wθ (P ) = Wθ (P ) ∪ Wθ+ π2 (P ) ∪ Wθ+π (P ) ∪ Wθ+ 32 π (P ).
The Rectilinear Convex Hull of P with orientation θ is the set
[
RHθ (P ) = R2 −
w.
w∈Wθ (P )
Figure 1(a) shows the rectilinear convex hull of a point set. The set Wθ (P )
changes along with θ and thus, RHθ (P ) is an orientation-dependent shape (Figure 1(b)). From this property, several optimization problems naturally arise for
RHθ (P ) when considering the complete set of θ-orientations of the plane.
Y
Yθ
θ
Xθ
X
(a)
(b)
Fig. 1: RHθ (P ) changes along with θ.
In this paper we solve the problem of computing all the values of θ ∈ [0, 2π)
for which RHθ (P ) has minimum area in optimal Θ(n log n) time and O(n) space.
We show that the set of orientations {θ : θ ∈ [0, 2π)} can be divided into a
linear sequence, {I1 , I2 , . . . , IO(n) }, of orientation intervals such that: (1) we can
compute the orientation θ ∈ I1 which minimizes the area of RHθ (P ) in O(n)
time; (2) We perform the computation of the orientation of optimal area for the
subsequent intervals in constant time. To obtain the set of orientation intervals
we use an optimal Θ(n log n) time and O(n) space algorithm. Our work is based
on techniques from Bae et al. [2], Avis et al. [1], and Dı́az-Báñez et al. [6]. Our
result improves the O(n2 ) time complexity solution presented recently by Bae
et al. [2].
Rectilinear convex hull with minimum area
2
3
The Un-oriented Rectilinear Convex Hull
In this section we present an algorithm to compute and maintain RHθ (P ) over
all the θ-orientations of the plane in Θ(n log n) time and O(n) space.
2.1
Preliminaries
In [10, 14] the Set Maxima Problem for a point set P in the plane is considered.
Concretely, given two points pi , pj ∈ P , the following dominance relation is
established: pi dominates pj (pj ≺ pi ), if xj ≤ xi and yj ≤ yi . The relation ≺
is a partial order in P . A point pi ∈ P is called maximal if there does not exist
pj ∈ P such that i 6= j and pi ≺ pj . The maxima problem consists of finding all
the maximal points of P under dominance. One can formulate maxima problems
for each quadrant in the plane. Each set of maximal points has a total ordering
and can be organized as a height balanced search tree. The maxima problem for
P with respect to any of the four quadrants can be solved optimally in Θ(n log n)
time and O(n) space [10, 14]. The set of maxima points for P with respect to
the four quadrants forms the rectilinear convex hull of P .
A vertex of RHθ (P ) is a point in P that lies on the boundary of RHθ (P ). For
any fixed θ, the computation of RHθ (P ) has a close relation to the Set Maxima
Problem [10, 14], since the set of vertices of RHθ (P ) is equal to the set Vθ (P )
of maximal points of P with respect to vector dominance in the four quadrants
defined by Xθ and Yθ [2, 6, 13].
Since we can specify RHθ (P ) using Vθ (P ), it is possible to keep track of the
changes in the set of vertices of RHθ (P ) over all θ-orientations in the plane,
by maintaining Vθ (P ) as the coordinate axes rotates counter-clockwise. The
maintenance of this set can be done using the results given in [1, 6] in the manner
we describe bellow.
We call apex of an orthogonal wedge to the intersection point of its supporting
lines. Every point p ∈ Vθ (P ) is the apex of a P -free orthogonal θ-wedge contained
in Wθ (P ). Figure 2 shows us a point p that is vertex of RHθ (P ) in the interval
Ip = [θ, θ0 ), and the orthogonal θ and θ0 -wedges with apex in p. The endpoints
of Ip mark the in- and out-events of p, i.e., the values of θ when p belongs
and stops being in Vθ (P ). Moreover, a point can be the apex of an orthogonal
θ-wedge during at most three intervals of θ-orientations. The next Theorem 1
appears in [6] not as a specific result but as a step of an Θ(n log n) time and
O(n) space algorithm of a fitting problem studied by the authors.
Theorem 1 (Dı́az-Bañez et al. [6]). To compute and maintain RHθ (P ) over
all θ-orientations can be done in optimal Θ(n log n) time and O(n) space.
To obtain Theorem 1, the authors compute first the set of orientation intervals in which the elements of P are maximal with respect to the four quadrants
defined by Xθ and Yθ (using a result from Avis et al. [1]), and also the ordered
set of in- and out-events. Both sets have a linear number of elements.
Let us denote by Vθ (P ) to the set of maximal points of P in the first quadrant
(P ).
defined by Xθ and Yθ . Note that Vθ (P ) = Vθ (P )∪Vθ+ π2 (P )∪Vθ+π (P )∪Vθ+ 3π
4
4
Rectilinear convex hull with minimum area
p
p
Xθ00
Xθ 0
Xθ
Xθ
(a) Ip = [θ, θ0 )
(c) θ00 ∈
/ Ip
(b) θ-orientation within
Ip
Fig. 2: A point p ∈ P , its orientation interval Ip and RHθ00 (P )
.
Since RHθ (P ) is an ortho-convex set, it is monotone with respect to Xθ . Thus,
the points of P in Vθ (P ) can be relabelled as v1 , . . . , vm in increasing order
according to Xθ . Let wi (θ) denote the P -free orthogonal θ-wedge supported
by two consecutive points vi , vi+1 ∈ Vθ (P ). We say that the wedges wi (θ) and
wj (θ + π) are opposite. If the intersection of wi (θ) and wj (θ + π) is nonempty,
then RHθ (P ) is disconnected (Figure 3b). In such case we say that wi (θ) and
wj (θ + π) overlap, and denote its intersection as Oθ (i, j).
vi
vi
vi
vi+1
vj+1
vi+1
vj+1
vj
vj
X 0
θ
X 0
θ
(a) Full interval start
vi+1
vj+1
X 00
θ
vj
X 0
θ
(b)
(c) Full interval end
Fig. 3: An overlap disconnects RHθ (P ). The ends of the overlap full interval.
Let Oθ (P ) be the set of all overlaps Oθ (i, j) of RHθ (P ) in the θ-orientation.
Oθ (P ) can be computed from Vθ (P ) in O(n) time, and RHθ (P ) can be computed
in Θ(n log n) time and O(n) space [10, 14] for a fixed value of θ. To maintain the
set Oθ (P ) we will compute an ordered list of angles as the one computed for the
in- and out- events. The overlap events do not necessarily match up with in- or
out-events [2], thus they have to be computed independently.
2.2
Overlaps characterization
As the θ-orientation rotates from 0 to 2π, the apex of every P -free orthogonal
θ-wedge supported by at least two points in Vθ (P ) traces an oriented circular
arc (Figure 4).
Definition 1. The arc-chain A(P ) of P is the closed curve formed by the union
of the set of arcs traced by the apices of the P -free orthogonal θ-wedges supported
by two consecutive elements of Vθ (P ) for some θ ∈ [0, 2π) (Figure 5).
Rectilinear convex hull with minimum area
(a) In-event
(b)
5
(c) Out-event
Fig. 4: The apices path as the θ-orientation changes.
The arc-chain can be computed in O(n) time using the in- and out-events
list: every arc is a segment of a circumference with diameter in consecutive points
(P ); and its ends correspond to the
of the sets Vθ (P ), Vθ+ π2 (P ), Vθ+π (P ), Vθ+ 3π
4
in- and out-events. Thus, each arc can be associated with an orientation interval
in which, the wedge that traces the arc is part of the rectilinear convex hull.
a6
a7
a4
a12
a0
a13
a3
a1
a2
pj
pj+1
link `j,j+1
a8
a9
Ai
(a) Numbered arcs
ei
(b) The sub-chain Ai (P ) in grey
Fig. 5: The arc-chain A(P ).
Let {e1 , . . . , eh } be the set of edges of the convex hull of P , CH(P ), in counterclockwise order. A sub-chain Ai (P ) ∈ A(P ) is a subsequence of consecutive
elements of A(P ), whose endpoints are the endpoints of ei . Ai (P ) is monotone
in the direction determined by ei . Thus, the orthogonal projection of Ai (P ) on
ei defines a total order ≺i on the set of endpoints of its arcs. Using the convex
hull edges and ≺i , we can label the arcs in A(P ) in counter-clockwise order, in
such a way that A(P ) = ha1 , . . . , al i (Figure 5a).
Assume that the ends of the arcs in any sub-chain Ai (P ) are labelled as
p1 , . . . , pm such that if r < s, then pr ≺i ps . A link `r,s is a subsequence pr , . . . , ps
of Ai (P ) such that for r < t < s, pr , ps ∈ P , pr ≺i pt ≺i ps and pt ∈
/ P.
Overlap characterization using the arc-chain. Let vi , vi+1 ∈ Vθ (P ) and let
vj , vj+1 ∈ Vθ+π (P ) that support two overlapping wedges wi (θ) and wj (θ + π),
respectively. If two opposite wedges in Wθ (P ) overlap, since these wedges are
P -free, the arcs traced by their apices belong to links that intersect (Figure 5a).
The overlap between wi (θ) and wj (θ + π) is possible only in an interval [θ0 , θ00 ]
where the θ0 -orientation is parallel to the segment vj+1 vi+1 , and in the θ00 orientation the Y -axis is parallel to the segment vi vj (Figures 3a and 3c). We
6
Rectilinear convex hull with minimum area
call full overlap interval to this orientation interval and we say that this interval
is a proper interval when θ0 ≤ θ00 .
Any arc aj corresponds to a particular P -free orthogonal θ-wedge wj (θ) for
every θ in some interval Ij = [θj1 , θj2 ]. An overlap is possible only between
opposite wedges. To determine if two given arcs aj , ak admit opposite wedges, we
define the facing interval for them as the interval If = [θj1 +π, θj2 +π]∩[θk1 , θk2 ].
Let aj and ak be arcs with their respective intervals Ij = [θj1 , θj2 ] and
Ik = [θk1 , θk2 ]. Let wj (θ) denote the orthogonal θ-wedge whose apex traces aj
for θ ∈ Ij and let wk (θ) denote the respective wedge of ak for any θ ∈ Ik .
Lemma 1. (Overlap in terms of arcs) The wedges wj (θ) and wk (θ) overlap if
and only if the full overlap interval is proper, the facing interval is not empty,
and the intersection between the full overlap interval and the facing interval is a
proper interval.
Thus, if there is an overlap between the wedges of given arcs, the overlap
interval is the intersection between the full interval, the facing interval, and the
intervals of both arcs. Let Ii,j be the interval of θ for which wi (θ) and wj (θ + π)
overlap. We call the ends of Ii,j the start- and stop- events of Oθ (i, j). The thick
arc segments show the overlap interval in Figure 6.
Xθ00
Xθ 0
(a) start-event
Xθ00
Xθ 0
(b) end-event
Fig. 6: The orientation interval of an overlap Ii,j = (θ0 , θ00 ).
If an overlap takes place, the links containing the arcs involved in the overlap
had intersected. Thus, it is possible to compute the overlaps and the start- and
end-events by computing the intersection points between links in the arc-chain.
Next we show that the number of those intersection points is at most O(n).
Lemma 2. Let a, b, c ∈ Ai (P ) such that a ≺i b ≺i c. Then,
π
2
≤ ∠abc < π.
As a consequence of Lemma 2, any link `r,s is contained in the disk that has
the segment pr ps as diameter, the link-disk Dr,s . Thus the number of links
that intersect the link-disk is greater than or equal to the number of links
that intersect `r,s . We denote by d(r, s) to the diameter of `r,s . Let D(P ) =
{D0 , D1 , . . . , Dh } be the set of disks such that Di has the convex hull edge ei as
a diameter and radius ri . By Theorem 1 in [1] we have.
Lemma 3. Given p, q ∈ P , the disk that has pq as diameter and radius r is
intersected by at most 28 disks Di ∈ D(P ) such that ri ≥ r.
Rectilinear convex hull with minimum area
7
For each of the disks in D(P ) that intersect a link-disk Dr,s , there is a constant number of links with diameter greater than d(r, s) that intersect `r,s .
Lemma 4. Let Di ∈ D(P ) be a disk of radius ri that intersects some given linkdisk Dr,s of radius d(r, s) < ri . There are at most five links in Di that intersect
`r,s with diameter greater than d(r, s).
Proof. Let R be the strip region bounded by the lines that project Dr,s on the
line containing ei (Figure 7a). Since sub-chains are monotone, the links in Ai (P )
that intersect Dr,s must have at least one endpoint in R.
Consider the links of Ai (P ) with endpoints in R. Suppose that all these links
have diameter greater than d(r, s). In order to have many links into region R,
the endpoints of these links should be placed as the configurations showed in
Figure 7. The configuration in Figure 7b considers three points pi−1 , pi , pi+1
such that pi is a peak (i.e., the distances from the other points to ei are smaller
than the distance between pi and ei ). In this case, with the help of a circle with
diameter parallel to ei of length d(r, s) that passes through pi−1 , it is possible
to show that: if pi must be at distance greater than d(r, s) from pi−1 and from
pi+1 , then pi cannot be part of a link in Ai (P ), because the angle ∠pi−1 pi pi+1
would be less than π2 , contradicting Lemma 2. Thus, since there are no crests
into region R, there is at most one valley (Figure 7c). Therefore there are at
most five links in Ai (P ) that intersect `r,s .
pi
1
ej
D
pr
5
2
pi−1
s)
d (r,
4
D
ps
3
pi+1
R
ei
d (r,s
)
(a) Links in Di intersecting `r,s
ei
ei
d( r, s)
d( r, s)
(b) No crest into R
(c) At most one valley
Fig. 7: A link `j,k can be intersected by at most five links contained in some Di ∈ D(P ).
The open area bounded by Ai (P ) and ei is P -free since it is covered by P -free
θ-wedges. Thus, two intersecting links have at least two intersection points, and
by Lemma 2 this number is tight, as none of the intersecting links can cross a
line segment joining its intersection points. From lemmas 2, 3 and 4 we have.
Lemma 5. Any link `j,k is intersected at most 280 times by links of diameter
greater than or equal to d(j, k).
8
Rectilinear convex hull with minimum area
The following result is a central tool for computing the start- and stop-events
list in O(n log n) time.
Theorem 2. There are O(n) intersections between links in A(P ).
2.3
Computing the start- and stop-events
We color the arcs in A(P ) in the following way: red if the arc belongs to a subchain that corresponds to an edge in the upper chain of the convex hull, and the
arc will be blue otherwise. Then we compute the bichromatic intersections using
Bentley-Ottmann plane sweep algorithm [3] in O(n log n) time and O(n) space.
Every intersection point will be associated with the respective links. After
sorting these intersection points lexicographically according to the labels of the
links involved in the intersection, we will be able to track corresponding pairs
of links (Figure 8), since this links correspond to a couple of intersection points
that involve the same links. We say that each of this couples form an alternate
link. For each alternate link, let Aα = {α1 , . . . , αv } (Aβ = {β1 , . . . , βw }) be the
set of red (blue) arcs comprised in the alternate link. Let us recall that an arc αi
is associated with an interval of orientations (θαi1 , θαi2 ). We say that θαi1 is the
left endpoint and θαi2 is the right endpoint of the interval. Using these intervals
we can verify in linear time if the conditions of Lemma 1 are fulfilled.
Fig. 8: A couple of links forming an alternate link.
3
Minimum area algorithm
The list of event points obtained in the previous section generate a set of orientation intervals (θ1 , θ2 ), in which the set of vertices of RHθ (P ) and the set
of overlaps in RHθ (P ) remains unchanged. For any θ ∈ (θ1 , θ2 ), the area of
RHθ (P ) is given by the following formula in [2]:
X
X
area(RHθ (P )) = area(P) −
area(4i (θ)) +
area(j (θ)).
i
j
Rectilinear convex hull with minimum area
9
The formula has three main components: the first is a polygon constructed by
joining counterclockwise consecutive vertices of RHθ (P ) (Figure 9a), the second
is the sum of the areas of triangles formed by consecutive vertices of RHθ (P )
and the apex of the P -free θ-wedge that they support (Figure 9b), finally the
third one is the sum of the overlaps area (Figure 9c).
(a) Polygon
(b) Triangles
(c) Overlaps
Fig. 9: Three main components.
In [2] the authors showed that area(4i (θ)) and area(j (θ)) of RHθ (P ) can be
expressed as a function of sin 2θ and cos 2θ; and used the derivatives to compute
the value θ ∈ (θ1 , θ2 ) for which the area of RHθ (P ) is minimized:
X
X
X
area0 (4i (θ)) = −
Ai sin 2θ +
Bi cos 2θ,
(1)
X
area0 (j (θ)) =
X
X
Ci cos 2θ −
Di sin 2θ.
(2)
It takes O(n) time to compute the area of the polygon for the first orientation
interval. This polygon changes with each in- and out-event. A point p is getting
in the RHθ (P ) between points vi , vi+1 (Figure 10a). The area of the polygon
that includes p can be computed in constant time from the area of the previous
polygon by subtracting the area of the triangle 4(vi , p, vi+1 ) (Figure 10b). In the
out-event of p, the area can be computed adding the area of the same triangle
(Figure 10c).
vi
vi
vi
vi+1
vi+1
vi+1
p
p
p
(a)
(b)
(c)
Fig. 10: Updating the area of the polygon
Using the in- and out-event list, it is possible to compute the set of triangles
that conform the second element of the formula. This list has a linear number of
changes, since on each in-event two triangles are added to the list and a triangle is
deleted form it and the same amount of triangles changes on each out-event. The
10
Rectilinear convex hull with minimum area
areas of the overlaps can be computed in a way similar, but using the ordered
list of the linear number of start- and stop-events. For each interval without
changes, we update the formula in constant time by subtracting or adding new
constant values. If there are more than one θ-orientation in which RHθ (P ) has
minimum area, our algorithm reports all of them. From the discussion above and
since CH(P ) can be computed from RHθ (P ) in O(n) time, we obtain:
Theorem 3. Computing the orientations for which the rectilinear convex hull
of P has minimum area can be done in optimal Θ(n log n) time and O(n) space.
References
1. Avis, D., Beresford-Smith, B., Devroye, L., Elgindy, H., Guévremont, E., Hurtado,
F., Zhu, B.: Unoriented Θ-maxima in the plane: complexity and algorithms. SIAM
J. Comput., 28(1), 278–296 (1999)
2. Bae, S.W., Lee, C., Ahn, H-K., Choi, S., Chwa, K-Y.: Computing minimum-area
rectilinear convex hull and L-shape. Computational Geometry: Theory and Applications, 42(3), 903–912 (2009)
3. Bentley, J., Ottmann, T.: Algorithms for reporting and counting geometric intersections. IEEE Trans. Computers C-28, 643–647 (1979)
4. Biedl, T., Genç, B.: Reconstructing orthogonal polyhedra from putative vertex
sets. Computational Geometry: Theory and Applications, 44(8), 409–417 (2011)
5. Biswas, A., Bhowmick, P., Sarkar, M., Bhattacharya, B.B.: Finding the orthogonal
hull of a digital object: a combinatorial approach. International Conference on
Combinatorial Image Analysis, 124–135. Springer-Verlag Berlin, (2008)
6. Dı́az-Báñez, J.M., López, M.A., Mora, M., Seara, C., Ventura, I.: Fitting a two-joint
orthogonal chain to a point set. Computational Geometry: Theory and Applications, 44(3), 135–147 (2011)
7. Fink, E., Wood, D.: Strong restricted-orientation convexity. Geometriae Dedicata,
69, 35–51 (1998)
8. Franěk, V., Matousěk, J.: Computing D-convex hulls in the plane. Computational
Geometry: Theory and Applications, 42, 81–89 (2009)
9. Khamsi, M.A., Kirk, W.A.: An introduction to metric spaces and fixed point theory. Wiley-Interscience (2001)
10. Kung, H.T., Luccio, F., Preparata, F.P.: On finding the maxima of a set of vectors.
Journal of the ACM, 22, 469–476 (1975)
11. Martynchik, V., Metelski, N., Wood, D.: O-convexity: computing hulls, approximations, and orientation sets. Canadian Conference on Computational Geometry,
2–7, (1996)
12. Matoušek, J., Plecháč, P.: On functional separately convex hulls. Discrete and
Computational Geometry, 19, 105–130 (1998)
13. Ottman, T., Soisalon-Soisinen, E., Wood D.: On the definition and computation
of rectilinear convex hulls. Information Sciences, 33, 157–171 (1984)
14. Preparata, F., Shamos, M.I.: Computational Geometry: An Introduction. SpringerVerlag (1985)
15. Rawlins, G.J.E., Wood, D.: Ortho-convexity and its generalizations. Computational Morphology: A Computational Geometric Approach to the Analysis of Form,
137–152. Elseiver Science Publishers B.V., North-Holland (1988)
16. Uchoa, E., De Aragão, M.P., Ribeiro, C.C.: Preprocessing Steiner problems from
VLSI layout. Networks, 40(1), 38–50 (2002)