0% found this document useful (0 votes)
21 views

Approximation Algorithms For Convex Hulls: Approximate O (N +

Uploaded by

dmz ardwn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Approximation Algorithms For Convex Hulls: Approximate O (N +

Uploaded by

dmz ardwn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Technical Notes Fig. 1. A Point Set and its Convex Hull.

Programming Techniques M . Douglas Mcllroy*


and Data Structures Editor
Approximation Algorithms
for Convex Hulls
Jon Louis Bentley and Mark G. Faust
Carnegie-Mellon University
Franco P. Preparata
University of Illinois at Urbana-Champaign
LL/
mediate step in many problems in computational ge-
The problem of constructing the convex hull of a ometry. For all these reasons, the computation of the
finite point set in a Euclidean space arises in many convex hull of a finite point set is an interesting algo-
applications. In this paper we study a set of algorithms rithmic problem.
for constructing approximate convex hulls. We show that Much work has recently been devoted to algorithms
an E-approximate hull of N points in the plane can be for computing convex hulls. Graham [4] proposed the
constructed in O(n + I/e) time. The planar algorithm has first algorithm for computing the hull of n planar points
been implemented and is very fast on point sets that in O(n lg n) worst-case time. (A number of different
arise in practice. The method can be generalized to worst-case algorithms have since been proposed for this
compute hulls of point sets in higher dimensional spaces. problem; see [8].) Preparata and Hong [7] later gave an
CR Categories and Subject Descriptors: F.2.2 [Anal- algorithm for computing the hull of n points in 3-space
ysis of Algorithms and Problem Complexity]: Nonnu- in O(n lg n) worst-case time. Shamos [8] was the first to
merical Algorithms and Problems--geometricalproblems show an f~(n lg n) lower bound on the problem of
and computations; G.2.1 [Discrete Mathematics]: Com- computing the polygon that is the edge of the planar
binatorics--combinatorial algorithms. convex hull; his proof makes crucial use of the fact that
General Terms: Algorithms, Design the vertices of the polygon must appear in sorted order.
Additional Key Words and Phrases: convex hulls, Yao [10] later achieved a much stronger result showing
approximation algorithms that merely identifying the extremal points of the hull
requires f~(n lg n) time. Because these lower and upper
bounds together establish the worst-case complexity of
I. Introduction
the problem to within a constant factor, researchers have
concentrated on other aspects of the problem. A partic-
The convex hull of a point set in Euclidean d-space is
ularly interesting problem is the expected complexity of
defined to be the smallest convex set containing the
computing convex hulls. Bentley and Shamos [1] showed
points; a set of points in the plane and its convex hull
that the hull of n points in 2-space or 3-space could be
are illustrated in Figure 1. Because it is a precise char-
computed in linear time for a large class of probability
acterization of the boundary of a point set, the convex
distributions. Devroye [3] extended their technique to a
hull is used in many applications; for example, Shamos
linear-time algorithm in d-space but for a much smaller
[8] discusses its use in such areas as robust estimation,
class of distributions. Many other aspects of convex hulls
Chebyshev approximation, least-squares isotonic regres-
have been discussed in the literature. Preparata [6], for
sion, and clustering. In addition to its inherent uses,
example, discusses a real-time on-line algorithm for con-
computation of the convex hull also arises as an inter-
structing planar hulls.
This research was supported in part by the Office of Naval In this paper we take an approach to the problem of
Research under Contract N00014-76-C-0370, in part by the National computing convex hulls that has not been explored in
Science Foundation under Grant MCS-78-13642, and in part by the any of the above papers. Specifically, we will investigate
Joint Service Electronics Program under Contract N00014-79-C-0424.
Authors' Present Addresses: Jon Louis Bentley and Mark G. Faust, the problem of computing an approximate convex hull.
Departments of Computer Science and Mathematics, Carnegie-Mellon Our algorithm runs in worst-case time linear in the
University, Pittsburgh, PA 15213; Franco P. Preparata, Coordinated number of input points, and computes an approximation
Science Laboratory, University of Illinois at Urbana-Champaign, Ur-
bana, IL 61801. that is arbitrarily close to the true hull. This algorithm is
* Former editor of Programming Techniques and Data Structures useful for applications that must have rapid solutions,
of which Ellis Horowitz is the current editor. even at the expense of accuracy. Thus the algorithm is
Permission to copy without fee all or part of this material is
granted provided that the copies are not made or distributed for direct particularly appropriate, for example, in statistical ap-
commercial advantage, the ACM copyright notice and the title of the plications where observations are not exact but are
publication and its date appear, and notice is given that copying is by known to a well-defined precision; there is no reason to
permission of the Association for Computing Machinery. To copy
otherwise, or to republish, requires a fee and/or specific permission. spend a great deal of time getting an accurate answer if
© 1982 ACM 0001-0782/82/0100--0064 $00.75. that accuracy is not really present in the underlying data!
64 Communications January 1982
of Volume 25
the ACM Number 1
Our technique is illustrated in the planar case in Sec. 2, Fig. 2. The Planar Approximate Hull Algorithm. (a) Place points in
bin. (b) Find extremes in bins. (c) Build hull of extremes.
and we examine applications of the algorithm to a num-
ber of problems in planar computational geometry in (a)
Sec. 3. Extension of these methods to higher dimensions
is then discussed in Sec. 4, and conclusions are offered
in Sec. 5.

• Q
2. The Planar Algorithm

In this section we study an algorithm for computing


an approximate convex hull of a planar point set. The
basic idea of the algorithm is simple: we judiciously
sample some subset of the points and then use the convex
hull of the sample as an approximation to the convex
hull of the points. (b)
The particular sampling scheme that we use is illus- r
trated in Figure 2. The first step of our algorithm is to
find the minimum and the maximum values in the x
dimension, and then divide the area between them into I •
k equally spaced strips; see Figure 2(a). Next, for each
strip, we find the two points in that strip with minimum
i" "I
and maximum y value (we call this set of points S); see
I
Figure 2(b). We also include in S the points with extreme
*-I
x values, and if there are several points with extreme x
values, we include both their maximum and minimum
by y value; there are therefore a maximum of 2k + 4
points in S. Finally, we construct the convex hull of S,
and use that as the approximate hull of the set; see
Figure 2(c). Note that the resulting hull is indeed only (c)
an approximation; one of the points of the set lies outside
it.
The method that we just sketched informally is easy
to implement as a computer program. Finding the mini-
mum and maximum x values is trivial, and the k-strips
are implemented as a (k + 2) element array (the zeroth
and (k + 1)st elements of the array contain only the
points with minimum ~ind maximum x value and are
present primarily as a programming convenience.) To
see in which strip a particular point falls, we subtract the
minimum x value from the point's x value, multiply that and the convex hull of S can be found in O(k) time
difference by the scaling factor of l / k times the differ- (because the, at most, 2k + 4 points in S are already
ence of the x extremes and take the floor of the product sorted by x value.) The running time of the entire
as the strip number. To find the minimum and maximum program is therefore O(n + k).
in each strip, we iterate through the point set, and for We have just shown that we can rapidly construct
each point check to see if it exceeds either the current some approximation to the hull, but before we can use it
maximum or minimum in the strip, and, if so, update a we must be precise about how accurate an approximation
value in the array. We then use one of the convex hull it is. One fact is easy to observe: because it uses only
algorithms described by Shamos [8] to compute the hull points in the input set as hull points, it is a conservative
of S. (The most natural algorithm for this problem is a approximation in the sense that every point within the
modified version of Graham's [4] algorithm which scans approximate hull is also within the true hull. We must
in right-to-left rather than counter-clockwise order.) now answer the question, "how far can a point be outside
The performance of this program is easy to analyze. the approximate hull if it is inside the true hull?" Note
The space that it takes is proportional to k (if we assume that the maximum distance is realized by one of the
the input points are already present.) Finding the mini- points in the input set. Let us assume that the distance
mum and maximum x values requires 8(n) time, and between the minimum and maximum x values is unity;
initializing the array can be accomplished in O(k) time. this implies that the width of each strip is 1/k. It is now
Finding the extremes in each strip requires 8(n) time, easy to prove the following fact.

65 Communications January 1982


of Volume 25
the ACM Number 1
Fact 1. Any point P in the point set that is not inside values of the points in S need not be stored), and has an
the approximate convex hull is within distance l / k of the error radius of l/2k, rather than 1/k.
hull.
To prove this, consider the strip in which P falls. Because 3. Applications of the Planar Algorithm
P is outside the approximate hull, it cannot have either In the last section we studied the approximation
the minimum or maximum y value of points in the strip; algorithm for convex hulls in an abstract setting; in this
P's y value must therefore lie between these two ex- section we study its application in a more concrete
tremes. Now draw a horizontal line from P to the hull; context. Specifically, we study a number of computa-
since the strip is l / k wide, this line can be at most that tional problems that can be quickly solved by using our
long, and the fact holds. approximation algorithm as though it produced the exact
This approximation error analysis can be used in hull.
either an absolute or a relative sense. If one wishes to The first problem that we will examine is that of
have an approximation accurate to within x units, then computing the diameter of a planar point set. It is easy
one can use strips of width x. For a relative error analysis, to prove that the diameter is realized by two points on
we can study the ratio of the error induced by the the convex hull, and Shamos [8] has shown that, given
approximation to the true diameter 1 of the point set, the hull, the diameter can be found in time linear in the
which we will denote by D. We will see in the next number of hull points. We can readily employ our
section that this is a natural measure of relative error. approximate hull algorithm in this context: we first find
Note that D is at least as great as the two points furthest the approximate hull, and then use its diameter as an
apart in the x dimension. We can now use Fact 1 (which approximation to the diameter of the entire set. This
assumed that the distance between x extremes is unity) requires O(N + k) time for constructing the approximate
to prove the following. hull and O(k) time for finding its diameter, for a total of
Fact 2. The relative error of a k-strip approximation O(N + k) time.
is at most 1/k. That is, anypoint in thepoint set that is not • To measure the efficacy of the approximation, let us
inside the approximate hull is within distance D / k of the assume that we did not find the true diameter D (which
hull, where D is the diameter of the point set. is realized by two points outside the approximate convex
hull) but rather that we found the approximate diameter
This fact is an immediate consequence of Fact 1. We will A, where A < D. By Fact 2, we know that both of the
investigate the use of this relative error approximation in points realizing the true diameter are within distance
the next section. D / k of the approximate hull. Applying this observation
The strip method of this section can be used to yield and the triangle inequality twice, we know that
various approximations. The approximation we just de-
scribed yields an approximate hull that is a subset of the D <_A + 2D/k,
true hull, but it is not hard to modify it to yield a superset which implies that
of the true hull. To do this, we just "move the x value"
of every maximal point P to be outermost in its strip (i.e., D - A <_ 2D/k.
away from the point realizing the maximum y value in We will take as a measure of our approximation the ratio
the point set if P is the maximum point in its strip, and of the difference of the approximate and the true diam-
similarly for the minimum points.) This can be viewed eters to the true diameter, which is
as covering the points in each strip with a rectangle
whose left and right sides are those of the strip and (D - A ) / D <_ 2/k,
whose top and bottom are given by the minimum and from the above equation. Thus we know that the ap-
maximum points. The approximate hull is then taken to proximate diameter produced by this method is a lower
be the convex hull of these covering rectangles. Because bound on the true diameter, and not more than 2D/k
the rectangles contain all the points in their strips, the less than the true. We can therefore compute E-approxi-
approximate convex hull properly contains the true con- mate diameters in O(n + l/e) time and O(l/e) storage.
vex hull. An error analysis similar to that above shows To illustrate the approximate diameter algorithm, we
that any point in the approximate hull but not in the consider the problem of finding the diameter of a point
true hull must be within distance l / k of the true hull. set to within one percent accuracy. For this accuracy, we
Yet another variation of the strip approach is to let k be 200, giving a maximum of 404 points in the 200
"align" all points to be in the center of their respective strips. A Pascal program implementing the algorithm
strip. The resulting hull is then provably neither a super- found the approximate diameter of a 25,000 element
set nor a subset of the true hull. This method, however, point set in 600 milliseconds of PDP-KL10 time. By way
is easier to program, more storage-efficient (since the x of comparison, a carefully coded Pascal program that
i The diameter of a point set is defmed as the m a x i m u m distance finds the diameter by computing all ( 2 ) interpoint
between any two points in the set, and is realized by two points on the
convex hull of the set (see [8].) distances and taking the maximum required approxi-

66 Communications January 1982


of Volume 25
the A C M Number 1
mately an hour and a half of CPU time. As a final application o f these approximation tech-
The diameter approximation algorithm we have just niques, we mention the problem of computing allfurthest
seen produces a lower bound on the true diameter by neighbors in a point set. Specifically, for each point in the
exhibiting two points in the set with distance provably set we must tell which point in the set is furthest from it.
close to the true diameter. In some applications, it might Since such a furthest neighbor must be a convex hull
be more desirable to have an upper bound on the di- point, given an approximate convex hull of k points we
ameter, and this can be easily achieved by the method can locate the approximate furthest neighbor of a new
described at the end o f Sec. 2. (This involves moving point in lg k time. 2 This method gives us the theoretical
each point "outward" in its strip, away from the point result that we can find all furthest neighbors in a set in
realizing minimum or maximum y value.) Finally, an O[(n + k) lg k] time, with each reported neighbor within
approximation that is neither an upper nor lower bound D/k o f the true furthest neighbor, where D is the diam-
but is within 1/k relative accuracy can be found by using eter of the point set.
only k strips and "placing" each point at the center of its
cell. This approach is especially appealing in applications 4. Extensions to Higher Dimensions
because the x values of the sample points need not be
stored (reducing the storage required from approxi- In previous sections we have studied approximation
mately 4k reals to 2k reals.) algorithms for planar convex hulls; in this section we
Two algorithms for computing approximate diameter turn our attention to convex hulls in d-space, where d
that are substantially different than the above have been > 2. We first study the case that d = 3, and then consider
given by Brown [2, Sec. 6.1]. His algorithms are based greater values of d.
on geometric transforms and require the computation of Our algorithm for computing an approximate convex
trigonometric functions. For a given sample size, his hull of a set of points in 3-space is an extension of the
approach yields a slight increase in accuracy over ours, planar algorithm described in Sec. 2. An initial sampling
but at a substantial increase in the constant factor of the pass finds the minimum and maximum values in both
run time. the x and the y dimensions; the resulting rectangle is
We turn now from the diameter problem to the then partitioned into (at most) a (k + 2) × (k + 2) grid
problem of convex hull searching. Precisely, we are given o f squares with lines parallel to the x and y axes. (We
a planar set of points and must organize it so that we can use k of the squares in each dimension for "real" points
quickly tell whether a new point is inside or outside the in squares, and the two squares on the end for the
convex hull of the set. We will investigate an approxi- extreme values.) Note that one of the dimensions can be
mation algorithm for convex hull searching that returns less than k + 2 if the point set does not happen to occupy
one of the three answers "yes, the point is definitely a square region. In each square of the grid we find the
inside the hull," "no, the point is definitely outside the points with minimum and maximum z values; the re-
hull," or "I do not know whether the point is inside or suiting set o f points, called S, consists of at most 2(k +
outside the hull, but it is within E of the hull boundary." 2) 2 points. Finally, we construct the convex hull of S and
Our first algorithm is based on the approximate hull use it as the approximate hull of the original set. The
algorithm that builds a subset of the true hull. We hull is constructed using Preparata and Hong's [7] gen-
construct the hull as before, in O(n + k) time. Consider eral hull algorithm for point sets in 3-space. Notice the
now the shape of the intersection of the approximate striking difference with respect to the two-dimensional
hull and any particular vertical strip used to make the method, where we were able to take advantage of the
hull; the top of the strip is bounded by one or two lines, known ordering of the points in the x dimension: we do
as is the bottom. We can therefore describe either the not exploit the grid structure of the points to yield a
top or the bottom by at most four reals (giving the values faster algorithm, but rather use a general algorithm. An
of the two y intercepts, and the possible point at which intriguing question is whether the regular placement of
the value changes.) To perform a hull search for point P, the points of S in a two-dimensional grid can be used to
we first locate the strip in which it lies in constant time obtain an algorithm more efficient than the general one.
by subtracting, multiplying, and taking the floor func- The analysis of the three-dimensional algorithm is
tion. We then use the stored values to see if it lies within somewhat different than that of the two-dimensional
the approximate hull, and if so, we correctly report that algorithm. The set S can be found in time O(n+ k 2) but
the point is inside the true hull. If it is further from the computing the convex hull of S using the general algo-
hull than the guaranteed error radius, then we correctly rithm requires time O(k 2 lg k 2) rather than O(k 2) since
report that the point is outside the hull. If neither of we are unable to exploit any natural ordering of the grid
these conditions holds then we respond that we do not points as we were in the two-dimensional case. Thus, the
know whether the point is inside or outside the hull. This
method requires O(n + k) time to organize the set and
constant time to answer a query. (Note that just as in the We are using here the fact that a set of M points can be processed
in O(M lg M) time to yield a furthest-neighborsearch time of O(lg
case of computing diameter, we could use other approx- M). Such an algorithm uses the furthest neighbor graph as discussed
imations to the hull.) in [8, Sec. 6.6] and the searching algorithm of Lipton and Tarjan [5].
67 Communications January 1982
of Volume 25
the ACM Number 1
total running time of the algorithm is O(n + k 2 lg k). 5. Conclusions
Using Preparata and Hong's algorithm, the storage space We have discussed an approach to computing convex
is O(k 2) beyond the space used for the n input points. hulls of point sets that quickly computes approximate
To determine the efficacy of the method, take as hulls of controlled accuracy. Precisely, the accuracy of
unity the larger of the x or y span of the originally given the result can be made to grow quickly with the expended
points in S. Since the diagonal of a grid cell has length computational work. The approach yields efficient
2~/2/k, this value is an upper bound of the distance from planar algorithms for hull construction, diameter finding,
the approximate hull to any point in the original set that and hull searching that are quite practical. These algo-
is external to the hull. As in Sec. 3 this bound can be rithms are also novel in a theoretical context; few ap-
used in either an absolute or relative sense. As before, proximate algorithms have been studied for problems
the approximate convex hull found by this method is a known to require polynomial worst-case time.
conservative one; other types of approximation are pos- A limitation of the approach is that it fails to yield
sible, by obvious generalizations of the cases discussed algorithms of comparable efficiency and simplicity in
in Sec. 2. three and higher dimensions. In this connection, there
We now turn our attention to applications of this remain some intriguing open problems regarding point
method. A simple way to find an approximate diameter sets that project onto grids. Is the construction of the
computes all pairs of diameters in S and returns the convex hull of a three-dimensional point set that projects
maximum; this gives a O(n + k 4) approximate diameter to a rectangular grid easier than the general case? Are
algorithm. Unfortunately, the best of the known general such sets easier for the determination of the diameter, or
algorithms for computing the diameter of a three-dimen- for the problem of hull searching?
sional set of M points [9] runs in time O[(M lg M)ls], In addition to the particular problems we have stud-
and thus yields an O[n + (k 2 lg k) 18] approximate ied, the more general contribution of this paper is the
diameter algorithm. Here again, it remains an intriguing entire approach of giving approximate answers. The
question whether the regular grid spacing of the approx- technique we used to achieve an approximate answer is
imate hull points can be exploited in some way to obtain straightforward and applicable in many contexts: we
a more efficient diameter algorithm. solve a smaller problem comprised of a judiciously cho-
A similarly disappointing conclusion is reached with sen sample of the input. The number of points in the
regard to the hull searching problem. Indeed, all that can sample controls the accuracy of the approximation, and
be said in general is that the polyhedral surface defining the way the sample is selected controls the type of
the hull is a triangulation of a set of grid points. It follows approximation (i.e., liberal or conservative.) These
that some cells of this grid may intersect as many as methods can prove to be a useful tool for practicing
O(k 2) faces of the polyhedron, so that no apparent programmers.
advantage originates from locating a target point in a Acknowledgment. The authors would like to thank
cell of the grid. It appears therefore that hull searching M.I. Shamos for suggesting the idea of approximation
must be solved by the standard technique, which trans- algorithms for the problems discussed in this paper.
forms the problem under consideration to a planar point
location and is solved in O(lg k) time (see, for example, Received 4/80; revised 10/80; accepted 6/81
Lipton and Tarjan [5].) Note that although lg k time is
References
high compared to the constant time of planar approxi- !. Bentley, J.L. and Shamos, M.I. Divide and conquer for linear
mate hull searching, it can be very small compared to lg expected time. Information Processing Lett. 7, 2, (Feb. 1978), 87-91.
N. 2. Brown, K. Q. Geometric transforms for fast geometric
algorithms. Ph.D. Thesis, Carnegie-Mellon University, December
The method that we have described to compute 1979. Carnegie-Mellon Computer Science Tech. Rept. CMU-CS-80-
approximate hulls in 2- and 3-space can easily be ex- 101.
tended to higher dimensions. In d-space we project the 3. Devroye, L. A note on finding convex hulls via maximal vectors.
Information Processing Letts. 11, 1, 53-56.
d-dimensional point set onto a (d - 1)-dimensional array 4. Graham, R.L. An efficient algorithm for determining the convex
of (d - 1) cubes with (at most) k + 2 cubes in each hull of a finite planar set. Information Processing Lett. 1, 132-133.
dimension. The approximate hull is constructed from the 5. Lipton, R.J. and Tarjan, R.E. Application of a planar separator
theorem. 18th Syrup. Foundations of Computer Science (Oct. 1977),
set S of minimum and maximum points in each grid cell, IEEE, pp. 162-170.
which is bounded above in size by 2(k + 2)d-1 points. 6. Preparata, F.P. An optimal real-time algorithm for convex hulls.
Any point inside the set yet outside the approximate hull Comm. ACM 22, 7, (July 1979). 402-405.
7. Preparata, F.P. and Hong, S.J. Convex hulls of finite sets in two
is at most distance (d - l)~/2/k from the hull, assuming and three dimensions. Comm. ACM 20, 2, (Feb. 1977), 87-93.
unity as the maximum distance between coordinate ex- 8. Shamos, M.I. Computational geometry. Unpublished Ph.D.
tremes. Note that a major drawback of this approach is Thesis, Yale University (May 1978), New Haven, Connecticut.
9. Yao, A.C. On constructing minimum spanning trees in k-
that S can be very large; we will consider the case of dimensional space and related problems. Stanford University
ensuring one percent accuracy for a set of points in 4- Computer Science Department Report STAN-CS-77-642, (Dec.
space. We must have (4 - 1)~/2/k < 0.01, so k _ 173. 1977).
10. Yao, A. C. A lower bound to finding convex hulls. Stanford
Because the size of S is 2(k + 2) 3, it contains approxi- University Computer Science Department Report STAN-CS-79-733,
mately 1.04 × 107 points! (April 1979).

68 Communications January 1982


of Volume 25
the ACM Number 1

You might also like