Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1

Receivd 31 Octobw 1977, awised wdon received28 December 1977

Convexhid, &orithm .

Introduction 1. Extrmud points

Several algorithms for determining the convex These are the four points with minimum and maxi;
hull of a set of points in two and three dimensions mum X and Y coordinates: say XMIN, Xl%kX,
have been published recently [l-6). It has also been YMIN, YMAX, respectively. From Fig. 1, two facts
established [3] that the complexity of the ‘L&men- are obvious,
sional convex hull problem is O(n log n). In this note (a) The extremal points must belong to the con-
we describe a new algorithm for obtaining the con- vex hull.
vex hull of a set of points in the plane and empiri- (b) Any point intericr to the cc Jvex quadrilateral
cally compare it to one of the best known algorithms. whose comers are the extremal pcints cannot belong
The simplicity and speed of the proposed algorithm to the convex hull,
make it worG reporting, It follows that by identifying the extremal points
one adds these points to the convex hull and discards
all points falling inside the quadrilateral the form.
The basic ideas We call this tie “throw-away” principle.
If there are several candidates with the same ei-
The algorithm is based on the fLllowing simple
ideas:
(1) Determining the four extremal points of the YMAX
.
set and discard@ all points interior to the convex .

quadrilateral t!ley form. .


. XMA ::
(2) Breaking the problem into four subproblems .

determinea by the extremal points. . .

e
(3) Using the vector cross-product to find the .
e
.
convex path in each problem. . l

These ideas ;tuenow explained in detail. We assume XMIN


. .
throughout *Ihefollowing discussion that points are .
I
e
given by their Cartesiancoordinates. <‘-
*
.
\

e
L./
* This research was supported by the National Research YM!N
Council of Catlada under grants NRC-A9293 and NRC-
A3599. Fig. I.

219
Vobme 7, number 5 INFORMATION PiKWSSING LE’M’ERS August 1978

.I
3. Vector cross-pivot
fuct

c
REGION 1 REGION 2
--Y
___-_--Y-
s
I’ f While examining the points in one of the regions
for inclusion in (or exclusion from) the convex hull,
assume that we are advancing along an edge of the
quadrilateral such that the region is at our left, as
shown in Fig. 2. A&nprnefirrther that we are looking
at three consecutive points k, k + 1, and k + 2. Ob-
viously if point k + 1 is as shown in Fig. 3(a) it is to
be kept temporarily, while it is to be discarded from
further consideration if it is as in Fig. 3(b).
If a, b and 8 are as shown in Fig. 3(a) and (b),
then the cross-product of the two vectors is given by
S=ubsinO

L R’GION 4 REGION 3 = @k+l - Yk)@k+2 - ‘ck+d


Fii. 2.
+ (xk - xk+l)@k+2 - Yk+l) l

treme x ory values their endpoints are kept as extre- Fig. 3(a), S is positive and in Fig. 3(b) it is negative.
In
mal points. For example, if several points have the We thus have the following simple ri.le:
same maxirn~*my coordinates only the leftmost and
If S > 0 keep point (k + 1) ,
rightmost of these are kept as YMAXextrema thus
yielding a possibly pentagonal “throw-away” region. else delete point (k + 1) .
Before presenting the algorithm we point out &at in
some cases two extremal points may coincide as
2. S~bpblerns
shown in Fig. 4. The sole effect of these situations
is that the number of subproblems is reduced.
Once the four extremal points have been deter-
mined, and some points eventually discarded, one
can break the remaining, set of points into four The algorithm
re$ir)ns,as shown in Fig. 2. All that remains is to
fn,ti a convex “path” from one extremal point tc the Step 1. Find the extremal points and delete all
other in the same region. other points falling inside the polygon they form.

s>o s<o
Fig. 3(a). Fig. 3(b).

220
VoIume7, numberS INFORMATION
PROCESSING
LETTERS August1978

Worst-caseant#ysi$

It is obvious that the computation is dotinated


bythe mrtifpg ~NKX@U~ in Step 2 (the IXQ at&et
stepshaving a nr*g3&ne proportions to n, the
XMIN:YMAX XMAX-YMAX \ number of pointi): In the wcxst case, when ail paints
I
lieonastraightkie,&e SOriinghasaCOmpkXi~ Qfo
log@.
(r-i

YMIN
Cbmparisonwith the al’rith~;! of Jawis
YMAX YMAX
P 3 REGIONS

The new algorithm and the algorithm of Jarvis [2]


aae programmed in FORTRAN for the IBM 3’701
158. Test problems werit generated randomly in the
XMAXzYMIN unit square using a uniform random number genera-
tot, In all problems tried the proposed algorithm ran
XMIN-YMAA mor3 than 3 times faster than the algorithm of
Jar&. Typically, run-time averages were as follows:
12 X 10” X n log PIseconds for the new p?gk’Lhm
and 40 X 10”’ X artlog n seconds for Jar-As”algo&&
XMAX-YMIN
(Note that the algorithm of Jarvis was progmmmed
following all possible improvements suggested in [a].)

Advantages of the new algorithm


Step 2. Sort the remaining points on their X-COOI-
dinate: in ascending order for regions 1 and 2 and The principal advantages of the new algorithm
descending order for regions 3 a& 4. can be summarized as follows:
8&p .3.For each region find the convex path (1) For large values of n it is safe to say that at
from one extremal point to the other using the {ol- least half the points are discarded in Step 1. This was
lowing rule: generally observed.
<C(l) Starting with one extremai point do (a) and (2) Breaking the problem into subrroblems by
@) below for every three consecutive points distributing the remaining points into the different
k, k + 1, k + 2 until the othet extremd point regions makes it easier (and therefore faster) to solve.
is reached. This is a good illustration of the divide-a&conquer
(a>Com.pute S. concept [S$1.
@) If S i> 0 move one point forward; else (3) The cross product criterion is very simple and
delete point (k + 1) and move one point inexpensive especially when compared to computa-
backward. tion of angles, as suggested by Graham [l] shifting
(2) If (1) is completed without any deletion, of axes, as suggested by Jarvis [2], or evaluation of
stop; else repeat (l)>> trigonometric functions as suggested by Andam
In Step 1 a point is assigned to either the quadri- WI l

lateral or one of the subregions using the point-in- Note that Step 3 in the above algorithm differs
polygon algorithm described in [ 10,ll ]I.Since at from Step 5 in Graham’s algorithm [l] in that, tlot
every iteration of S&p 3(l) a finite q-umber of points only are angles not computed, but the endpoints in
is removed, convergence of the algorithm is guaran- the convex path in each subregion are kno~~~ thus
teed. The remaining points :km the convex hull of yielding a simpler: termination criterion than that
the original set. suggested ti [ 161.
Voim 7, number 5 INFGRMATIGN PRIXESSING LETTERS August 1978

Conchsion sional convex hull of a polyhedron, IBM J. Res. and


Devel., 210(Nov. 1976) 590-601.
F.P. Preparata and S.J. Hong, convex liuIIs of finite
A new aIgorithm has been presented for deter-
sets of points in two and three dtitiensions, CACM,
mining the convex huU of a set of points in the plane. 20 (Feb. 1977) 87-93.
A very efficient preprocessing procedure as well as a PI R.A. Jarvis, Computing the Shape HuII of Points in the
novel criterion for identifying convex points were Plan-;, Proc. of tie IEEE Comp. Sot. Conf. on Pattern
described. Due to its high speed the algorithm ia Recognition and Image Pror~~sing, Troy, N.Y. (June
1977) 231-241.
recommended for applications where computation
(71 MI. Shamos, Geometric Complexity, Proc. of the
time is the primary factor, such as the Monte Carlo Seventh Annual ACM Symposium on the Theory of
studies considered in [9]. Computing, Albuquerque, NM. (1975) 224-233.
An iterative version of this algorithm that repeat- 181A.V. Alto, 3.E. Hopcroft and J.D. UiIman, The Design
edly uses the “throw-away” principle and does not and Analysis of Computer Algorithms (Addison-
Wesley, Reading, MA, 1976).
sort appears in [ 121. K.R. Anderson [ 141 of M.I.T.
PI S. Akl, On a generalization of Sylvester’s ProbIem and
has independently r bered a similar implementa- Some Convex HuiI Expectations, Internal Report,
tion of this basic 1. -I;ring the reviewing process. School of Computer Science, McGiIi University.
‘Weshow in [ i2j md [ 131 tit the iterative algorithm WI M. Shimrat, Algorithm 112: Position of point retative
has worst case complexity of o(n log n) and an asymp- to polygon, Comm. A.C.M., 5 (August 1962) 434.
totic exprxted run time behaviour of O(n). WI R. Hacker, Certification of algorithm 112 position of
point relative to polygon, Comm. A.C.M., 5 (December
1962) 606.
Refemnm ’ WI G.T. Toussaint and S.G. AH, Convex huII algorithms
in two and more dimensions (manuscript in prepara-
tion).
[11 RL. Graham, An efficient algorithm for determining t131 S.G. Aki and G.T. Toussaint, Efficient convex huli
tht: Convex Hull of a Finite Pianar Set, Information algorithms for pattern recognition applications (sub-
Processing Lett., 1 (1972) 132-133. mitted for publication).
(21 RA. Jawis, On the Idetitification of the Convex HuIl WI K.R. Anderson, personal communication.
of a finite set of points in the plane, Information WI K.R. Anderson, A reevaluation of an efficient aigorithm
Processing Lett., 2 (1973) 18-21. for determining the convex huii of a finite planar set,
(311M-I. Shames and D. Hoey, closet point problems,i, Information Processing Lett. 7 (January 1978) 53-55.
Proc. of the Sixteenth Annual Symposium on Founda- WI J. Koplowiti and D. Jouppi, A more efficient convex
tions of Comp. SC., IEEE, N.Y. (1975) 151-162. hull algorithm, Information Processing Lett. 7
[4] A. Appel ‘and P.W. Wiil, Determining the three dimen- (January 1978) 56-57.

222

You might also like