Convex Sets - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Convex Sets

Description:

Rubber band. When Q is finite, its convex hull is the unique convex polygon whose vertices ... line passing through p and q. Floating Arithmetic is not Exact! ... – PowerPoint PPT presentation

Number of Views:127
Avg rating:3.0/5.0
Slides: 27
Provided by: toshi155
Category:
Tags: and | convex | sets

less

Transcript and Presenter's Notes

Title: Convex Sets


1
Convex Sets Concave Sets
A planar region R is called convex if and only if
for any pair of points p, q in R, the line
segment pq lies completely in R.
Otherwise, it is called concave.
2
An Example
4
1
2

3
3
Convex Hull
The convex hull CH(Q) of a set Q is the smallest
convex region that contains Q.
Rubber band
When Q is finite, its convex hull is the unique
convex polygon whose vertices are from Q and
that contains all points of Q.
4
The Convex Hull Problem
Input a set P p , p , , p of points
1 2 n
Output a list of vertices of CH(P) in
counterclockwise order.
Example
5
Edges of a Convex Hull
For every edge both endpoints p, q ? P.
q
p
6
Floating Arithmetic is not Exact!
Nearly colinear points p, q, r.
q
r
p
All three accepted as edges!
Not robust the algorithm could fail with small
numerical error.
7
Polar Angle
y
q
polar angle
p
x
r
8
An Example of Graham Scan
Sort by polar angle.
(with the minimum y-coordinate)
How to break a tie?
Labels are in the polar angle order.
(What if two points have the same polar angle?)
9
Stack Initialization
p
p
6
9
p
p
7
4
p
11
p
p
8
p
5
10
p
3
p
p
2
1
p

0
10

p
p
6
9
p
p
7
4
p
11
S
p
p
8
p
5
10
p
p
3
3
p
1
p
p
2
1
p
0
p

0
11

p
p
6
9
p
p
7
4
p
11
S
p
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
12

p
p
6
S
9
p
p
7
4
p
11
p
p
p
5
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
13

p
p
6
S
9
p
p
7
4
p
11
p
p
6
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
14

S
p
p
8
p
6
9
p
p
p
7
4
7
p
11
p
p
6
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
15

S
p
p
6
9
p
p
p
7
4
7
p
11
p
p
6
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
16

S
p
p
10
p
6
9
p
p
4
9
p
p
11
7
p
p
6
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
17

S
p
p
11
p
6
9
p
p
4
9
p
p
11
7
p
p
6
p
8
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
18
Finish
S
p
p
11
p
6
9
p
p
4
9
p
p
11
p
7
p
8
6
p
p
5
10
p
p
4
3
p
1
p
p
2
1
p
0
p

0
19
Grahams Scan
candidates for vertices of CH(P)
vertices of CH(P) in the counter- clockwise orde
r.
20
The Graham Scan Algorithm
Graham-Scan(P) let p be the point in P
with minimum y-coordinate let ? p , p ,
, p ? be the remaining points in P
sorted in counterclockwise order by polar
angle around p . TopS ? 0
Push(p , S) Push(p , S) Push(p ,
S) for i ? 3 to n ? 1 do
while p makes a nonleft turn from the line
segment determined by
Top(S) and Next-to-Top(S)
do Pop(S) Push(S, p )
return S
0
1 2 n1
0
0
1
2
i
i
21
Proof of Correctness
Claim 1 Each point popped from stack S is not a
vertex of CH(P).
Two cases when p is popped
Proof
j
22

Claim 2 Graham-Scan maintains the invariant
that the points on stack S always form the
vertices of a convex polygon in
counterclockwise order.
Proof
Popping a point from S preserves the invariant.
The invariant still holds.
23
Correctness of Grahams Scan
Theorem If Graham-Scan is run on a set P of at
least three points, then a point of P is on
the stack S at termination if and only if
it is a vertex of CH(P).
24
Running time
operations time / operation total
Sorting 1 O(n lg n)
O(n lg n)
Push n O(1)
?(n)
Pop ? n ? 2 O(1)
O(n)
Why?
The running time of Grahams Scan is O(n lg n).
25
Jarvis March
A package wrapping technique
Right chain
Left chain
26
Running Time of Jarviss March
Let h be the number of vertices of the convex
hull.
For each vertex, finding the point with the
minimum Polar angle, that is, the next vertex,
takes time O(n).
Comparison between two polar angles can be
done using cross product.
Thus O(nh) time in total.
Write a Comment
User Comments (0)
About PowerShow.com