Convex Hulls

Convex Hulls
Shmuel Wimer
Bar Ilan Univ., Eng. Faculty
Technion, EE Faculty
May 2012
E : d -dim insional E uclidean space.
G iven k distinct points p1 , p 2 ,
points p   1 p1   2 p 2 +
1  i  k , and
by p1 , p 2 ,
p1 , p 2 ,
i 1
, p k in E , the set of
+  k p k ,  i  R ,  i  0,
 i  1, is the con vex set generated
, p k , and p is the con vex com bin ation of
,p k .
G iven L an arbitrary set of points in E , the con vex h u ll
conv  L  is the sm allest convex set containing L .
May 2012
A polyh edral set in E
is the intersection of finite set
of closed half-spaces (one side of a hyp erplane) in E .
C onvex d - polytop is a bounded polyhedral set in E .
T h eorem : T he convex hull of a finite set of poin ts in
is a convex polytop. C onversely, a conv ex polytop
is the convex hull of a finite set of po ints.
2-polytop is a convex polygon, specified by the ordered
set of its vertices.
May 2012
3-polytop is a polyhedron com pletely spe cified by its
vertices, edges and faces. Its projection on the plane
or sphere is a planar graph. It follow s from E uler's
form ula that the num ber of vertices e dges and faces
of a 3D polyhedron are linearly related.
H ow difficult is to find the convex hull of N points in
the plane?
T h eorem : S orting can be transform ed in linear-ti m e
to finding convex hull in the plane. Fin dingthe convex
hull of N points requires therefore   N log N
May 2012
t im e.
P roof : G iven N real positive num bers x1 , x 2 ,
consider the N points
,x N ,
 x i , x i   R 1  i  N . T his
transform ation takes linear tim e,
T he N points are the vertices
a convex polygon in the of
y  x
Finding the polygon results
in the sorting of
x1 , x 2 ,
, x N , and the low er
bound   N log N
May 2012
follow s.
Convex Hull Algorithms in the Plane
A point p of a convex set S is extrem e if no tw o points
a , b  S exist such that p   a , b  .
T he set E of extrem e points in S is the sm allest subset
of S such that conv  E  = conv  S  and E is the set of
conv  S  vertices.
Finding conv  S  of finite set of points S ca n be
done by:
1. identifying its extrem e points, and
2. order those so that they form a conve x polygon.
May 2012
T h eorem : A point p fails
to be an extrem e point of a
plane convex set S only if
it lies in som e triangle w ith
vertices in S but is not itself
a vertex of the triangle.
C orollary : L et S  N . T he extrem e points of
conv  S  can be found in O  N
tim e.
T he nature of the order of extrem e point s is revealed
by the follow ing properties.
May 2012
A ray em anating from an interior point o f a convex
bounded figure F is intersecting the boun dary of F
in exactly one point.
C onsecutive vertices of a convex polygon occur in
sorted angular order about any interior point.
q can be found in
May 2012
O  1  tim e.
vertices are sorted
in O  N log N
tim e.
Graham’s Scan
To determine whether a point is extreme, is it necessary to
examine all triangles?
R. L. Graham showed in 1972 that sorting the point first, the
extreme points can be found in linear time.
Suppose an internal point was found and was set as the
origin, while all points are trivially transformed accordingly.
The points can be sorted lexicographically by angle and
distance from origin. The points are then stored in doublylinked circular list.
No divisions or square roots are needed.
May 2012
Scan starts at the lowest
rightmost point which is
certainly extreme.
It repeatedly examines
triples of consecutive points
to determine whether or not
they define a reflex angle.
The following rules apply:
1. p1p2p3 is a right turn. Eliminate p2 and check p0p1p3.
2. p1p2p3 is a left turn. Advance the scan and check p2p3p4.
May 2012
Theorem: The convex hull of N points in the plane can be
found in O(NlogN) time and O(N) storage, using only
arithmetic operations and comparisons.
The sort of polar coordinate (divisions and square toot are not
necessary) can be replaced by left to right sorting as follows.
Upper subset
Split into upper and
lower points by the
the leftmost and
Lower subset
May 2012
line passing through
rightmost points
Construct the upper and lower boundaries separately by
left to right scan of the sorted points, and applying same
rules for reflex angles. The points l and r are necessarily
on the boundary.
May 2012
Jarvis’s March
A polygon can be described by the sequence of its edges,
similar as the sequence of vertices. Given two points, it is
straightforward to test whether the line segment joining
them is an edge of the convex hull.
Convex hull p
Theorem: The line segment
l defined by two points is
an edge of a convex hull iff
all other points of the set
lie on l or to one side of it.
May 2012
There are O(N2) edges to examine. For each, all N points are
tested, yielding O(N3) run time.
O nce a segm ent p q is found to be a hull ed ge, there m ust
be a succesive edge qr , and O  N
tests suffice .
The algorithm finds
successive hull vertices
by repeatedly turning
angles. New vertex is
discovered in O(N) time,
May 2012
yielding O(N2) total time.
In the worst case where all N points lie on the convex hull
Jarvis’s march consumes O(N2) time, which is inferior to
O(NlogN) Graham’s scan run time. In many cases where the
number of convex hull points is h and h<<N, run time is O(hN).
Jarvis’s march is reminiscent of gift-wrapping, and can be
extended to 3D, while Graham’s scan does not.
May 2012
QUICKHULL Techniques
Inspired by QUICKSORT sorting algorithm (Hoare 1962).
Reminder: QUICKSORT worst case run time is O(N2).
Expected runs time is O(NlogN) (division of set into two
subsets, adhering some “balance” criterion).
QUICKHULL works recursively. It partitions the set S of N
points into two subsets each results in a polygonal chain.
The chains concatenations yields the convex hull polygon.
The initial partitioning is defined by the line passing through
the points with the smallest and largest abscissae.
May 2012
(1, 2 )
May 2012
Find h  S
 hlr 
such that the triangle
is m axim al am ong all triangles
w hose area
plr  p  S
 . If
there are few m axim al triangles, pick th e one w ith
largest angle   plr  . T he point h is guaranteed to
belong to the convex hull.
T he points outside triangle
sets. S
 hlr 
split into sdisjoint
are those left to L1 and S
to L 2 . T he chains obtained from S
(1, 2 )
are those left
and S
(1, 2 )
concatenated to form the upper chain w ith respect to
lr .
May 2012
point chain Q U IC K H U L L ( point set S ; point l , r ) {
if ( S   l , r  ) return
l, r  ;
// convex hull is an ed ge
else {
// get apex of m ax area tr ian g l e
h  F U R T H E S T ( S , l , r );
 points of S l eft t o lh ;
 points of S left to hr ;
// chain concatenation
return Q U IC K H U L L ( S
, l , h )+
Q U IC K H U L L ( S
, h , r );
May 2012
Finding the point which maximizes the area of the triangle takes
O(N). Chain concatenation takes O(1). Therefore, if the size of
point subsets adheres some balance, the run time is O(NlogN).
As QUICKSORT, worst run time is O(N2).
Though QUICKHULL is a divide-and-conquer algorithm, the
uncontrolled size of the two remaining parts results square
worst-case time complexity. Moreover, the algorithm that
inherently can be parallelized, may suffer from inefficiency
due to poor balancing.
May 2012
Divide-and-Conquer Algorithms
Suppose the point set S is divided into two arbitrary halves S1
and S2, where there is no separation between S1 and S2. Let us
compute the convex hulls CH(S1) and CH(S2). How much work
is required to form CH(S1US2)?
It follow s from C H  S 1
S 2   C H  C H  S1 
CH  S2 
that w e can w ork recursively. T he key qu estion is how
efficiently can tw o convex hulls be m erg ed?
May 2012
If U  N
is the tim e required for m erging and T  N
is the total run tim e, then T  N   2 T  N 2   U  N  .
C H  C H  S1 
CH  S2 
T o obtain T  N   O  N log N  ,
there m ust exist U  N   O  N  .
Theorem: The convex hull of the union of two convex polygons
can be found in time proportional to their total number of
May 2012
P roof : P1 and P2 are convex polygons.
1. Find a point p internal
to P1 (centroid of three
vertices). It follow s that
p  C H  P1
P2  .
2. D eterm ine w hether p  P2 (can be done in O  N
t im e).
In that case the vertices of both P1 a nd P2 occur in angular
sorted order about p .
P1 and P2 can be m erged in O  N
tim e by traversi ng
their vertices in opposite angular order about p .
May 2012
3. p  P2 . A w edge  vpu  
is thus defined and u and v
can be found. T he inner
chain of P2 from u to v can
be discarded. A ll this takes
T he points of the outer chain of P2 are so rted by angular
order about p , and sam e for P1 . T he tw o lis ts are m erged
tim e. G raham 's scan can now find C H  P1
tim e.
4. G raham 's scan can find C H  P1
May 2012
P2  in O  N
P2  in
tim e. 

similar documents