convex hulls may 20121 shmuel wimer bar ilan univ., eng. faculty technion, ee faculty

24
Convex Hulls May 2012 1 Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty

Upload: primrose-pope

Post on 17-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

1

Convex Hulls

May 2012

Shmuel WimerBar Ilan Univ., Eng. Faculty

Technion, EE Faculty

2

Preliminaries

May 2012

1 2

1 1 2 2

1

1 2

: -diminsional Euclidean space.

Given distinct points , , , in , the set of

points + + , , 0,

1 , and 1, is the generated

by , , , , and is the

d

dk

k k i i

k

ii

k

d

k p p p

p p p p

i k

p p p p

E

E

convex set

R

1 2

of

, , , .kp p pconvex combination

Given an arbitrary set of points in , the

conv is the smallest convex set containing .

dL

L L

E convex hull

3May 2012

A in is the intersection of finite set

of closed half-spaces (one side of a hyperplane) in .

d

d

polyhedral set E

E

Convex is a bounded polyhedral set in .dd - polytop E

The convex hull of a finite set of points in

is a convex polytop. Conversely, a convex polytop

is the convex hull of a finite set of points.

d

:Theorem

E

2-polytop is a convex polygon, specified by the ordered

set of its vertices.

4May 2012

3-polytop is a polyhedron completely specified by its

vertices, edges and faces. Its projection on the plane

or sphere is a planar graph. It follows from Euler's

formula that the number of vertices edges and faces

of a 3D polyhedron are linearly related.

How difficult is to find the convex hull of points in

the plane?

N

Sorting can be transformed in linear-time

to finding convex hull in the plane. Findingthe convex

hull of points requires therefore log time.N N N

:Theorem

5May 2012

1 2

2 2

Given real positive numbers , , , ,

consider the points , 1 . This

transformation takes linear time,

N

i i

N x x x

N x x i N

: Proof

R

The points are the vertices

a convex polygon in the of

plane.

N

2y x

x

y

1 2

Finding the polygon results

in the sorting of

, , , , and the lower

bound log follows.Nx x x

N N

6

Convex Hull Algorithms in the Plane

May 2012

A point of a convex set is if no two points

, exist such that , .

p S

a b S p a b

extreme

The set of extreme points in is the smallest subset

of such that conv = conv and is the set of

conv vertices.

E S

S E S E

S

Finding conv of finite set of points can be

done by:

1. identifying its extreme points, and

2. order those so that they form a convex polygon.

S S

7May 2012

A point fails

to be an extreme point of a

plane convex set only if

it lies in some triangle with

vertices in but is not itself

a vertex of the triangle.

p

S

S

:Theorem

4

Let . The extreme points of

conv can be found in time.

S N

S O N

:Corollary

1p3p

2p

0p

The nature of the order of extreme points is revealed

by the following properties.

8May 2012

A ray emanating from an interior point of a convex

bounded figure is intersecting the boundary of

in exactly one point.

F F

Consecutive vertices of a convex polygon occur in

sorted angular order about any interior point.

1p

2p

3p

4p

5p

6p

7pq

P

can be found in

1 time.

vertices are sorted

in log time.

q

O

O N N

9

Graham’s Scan

May 2012

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 doubly-

linked circular list.

No divisions or square roots are needed.

10May 2012

O

2p1p

3p

Start

Scan

0p

Scan starts at the lowest

rightmost point which is

certainly extreme.

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.

It repeatedly examines

triples of consecutive points

to determine whether or not

they define a reflex angle.

11May 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.

Lower subset

ScanUpper subset

l

r

Split into upper and

lower points by the

line passing through

the leftmost and

rightmost points

12May 2012

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.

13

Jarvis’s March

May 2012

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.

p

q

p

q

Convex hullTheorem: 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.

14May 2012

There are O(N2) edges to examine. For each, all N points are

tested, yielding O(N3) run time.

Once a segment is found to be a hull edge, there must

be a succesive edge , and tests suffice.

pq

qr O N

The algorithm finds

successive hull vertices

by repeatedly turning

angles. New vertex is

discovered in O(N) time,

yielding O(N2) total time.

4p

3p

2p

1p

15May 2012

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.

16

QUICKHULL Techniques

May 2012

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.

17May 2012

l

r

(1)S

(1,2)S

(1,1)S

1L

2L

h

18May 2012

(1)

(1)

Find such that the triangle whose area

is maximal among all triangles . If

there are few maximal triangles, pick the one with

largest angle . The point is guaranteed to

belong to

h S hlr

plr p S

plr h

the convex hull.

(1,1) (1,2)

1

(1,1) (1,2)2

The points outside triangle split into sdisjoint

sets. are those left to and are those left

to . The chains obtained from and are

concatenated to form the upper chain

hlr

S L S

L S S

with respect to

.lr

19May 2012

(1)

// convex hull is an ed( ; , ) {

( , ) return , ; {

( , , );

points of

ge

// get apex of max area tr

l

ian

eft

l

e

t

g

point chain point set S point l rif S l r l r

else

h S l r

S S

QUICKHULL

FURTHEST

(2)

(1)

(2)

o ;

points of left to ; ( , , )+ ( , , );

// chain concatenation

}}

lh

S S hr

return S l hS h r

QUICKHULLQUICKHULL

����������������������������

20May 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.

21

Divide-and-Conquer Algorithms

May 2012

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)?

1 2 1 2It follows from CH CH CH CH

that we can work recursively. The key question is how

efficiently can two convex hulls be merged?

S S S S

22May 2012

If is the time required for merging and

is the total run time, then 2 2 .

U N T N

T N T N U N

1 2C H HCH CS S

Theorem: The convex hull of the union of two convex polygons

can be found in time proportional to their total number of

vertices.

To obtain log ,

there must exist .

T N O N N

U N O N

23May 2012

1

1 2

1. Find a point internal

to (centroid of three

vertices). It follows that

CH .

p

P

p P P

1 2 and can be merged in time by traversing

their vertices in opposite angular order about .

P P O N

p

1 2 and are convex polygons.P P:Proof

2

1 2

2. Determine whether (can be done in time).

In that case the vertices of both and occur in angular

sorted order about .

p P O N

P P

p

24May 2012

2

2

3. . A wedge

is thus defined and and

can be found. The inner

chain of from to can

be discarded. All this takes

p P vpu

u v

P u v

1 24. Graham's scan can find CH in time.P P O N

2

1

1 2

The points of the outer chain of are sorted by angular

order about , and same for . The two lists are merged

time. Graham's scan can now find CH in

time.

P

p P

O N P P

O N