A planar region is called convex if and only if for any pair of points in the line segment lies completely in Otherwise it is called concave Convex ID: 911237
Download Presentation The PPT/PDF document "Convex Sets & Concave Sets" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Convex Sets & Concave Sets
A planar region is called convex if and only if for any pair of points , in , the line segment lies completely in .
Otherwise, it is called
concave.
Convex
Concave
Slide2An Example
1
2
3
4
Regions 1 & 2: convex
Regions 3 & 4: concave
Slide3Convex Hull
The convex hull CH() of a set is the smallest convex regionthat contains .
Rubber band
When
is finite, its convex hull is the unique
convex polygon
whose vertices
are from
and that contains all points of
.
Degenerate Cases
♦
The convex hull of a single point is itself. ♦ The convex hull of several collinear points is the line segment
joining the two extreme points.
Slide5The Convex Hull Problem
Input: a set
of points
Output: a list of vertices of CH() in counterclockwise
order.
Example
Output:
,
,
, ,
, .
(direction of traversal about the
outward axis with the interior
on the left)
Slide6Edges of a Convex Hull
For every edge with endpoints
.
p
q
All other points in
lie
to the same side of the line passing through
and
A Slow Convex Hull Algorithm
Slow-Convex-Hull() // set of directed edges of CH() that bounds the // points of
P on the right. for every ordered pair
, where
and //
pairs
do valid true for every point or
//
such points do if lies to the right of
or
collinear with and but not on then valid false
if valid then //
and cannot be both in From construct a list of vertices of CH(), sorted in counterclockwise order.
//
improvable to return L
Running time
Floating Arithmetic is not Exact!
p
r
q
Nearly colinear points
p
,
q
,
r
.
p
to the left of
qr
.
q
to the left of
rp
.
r
to the left of
qp
.
All three accepted as edges!
Not
robust
– the algorithm could fail with small numerical error.
Slide9Polar Angle
p
polar angle
Graham Scan
1) Select the node with the smallest
coordinate.
This node will be a vertex of the convex hull.
Slide11Tie Breaking (1)
When more than one point has the smallest
coordinate, pick
the
leftmost
(or rightmost) one.
Sorting by Polar Angle
Labels are in the polar angle order.
2) Sort by polar angle with respect to
.
No Polar Angle Evaluation
is the lowest (and leftmost)
a
ll polar angles
if
Tie Breaking (2)
What if
Order them by distance from
.
if and
No square roots.
Use dot product!
Slide15Point Elimination
When multiple points have the same polar angle, keep the onefurthest from .
Remove
the rest since they cannot possibly be the hull vertices.
furtherest
remove
Stack Initialization
3)
S
maintaining a stack.
Finish
S
Graham’s Scan
Every point
in
is
pushed onto
once
Non-vertices
of
CH(
)
determined
so far are
popped
vertices of
CH(
)
in the
counter-
clockwise
order.
candidates
for vertices
of
CH(
)
start
finish
Slide27The Graham Scan Algorithm
Graham-Scan() let be the point in with minimum
-coordinate let
be the remaining points in sorted in counterclockwise order by polar angle around
.
Top[] 0 Push(, )
Push(
, ) Push(
,
) for to do while
makes a nonleft turn from the line segment determined by Top() and Next-to-Top(
) do Pop() Push(, )
return
Running time
The running time of Graham’s Scan is
#operations time / operation total
Push
Pop
Sorting
1 O(
)
Why?
Finding
1
Proof of Correctness
Claim 1 Each point popped from stack S is not a vertex of CH(P).
Two cases when
is popped:
In neither case can
become a vertex of CH(
P
).
Proof
Slide30Claim 2 Graham-Scan maintains the invariant that the points on stack S always form the vertices of a convex polygon in counterclockwise order.
Popping a point from
preserves the invariant.
The region
containing
The invariant still holds.
Proof
The claim holds right after initialization of
when
form a triangle (which is obviously convex).
Consider a point
being pushed onto
.
Correctness of Graham’s Scan
Theorem If Graham-Scan is run on a set of at least three points, then a point of is on the stack S at termination if and only if it is a vertex of CH(P).
Jarvis’ March
A “package wrapping” technique
(lowest point)
(smallest polar
angle
w.r.t.
)
(smallest polar
angle
w.r.t.
)
Right
chain
(smallest polar
angle
w.r.t.
)
(smallest polar
angle
w.r.t.
)
(smallest polar
angle
w.r.t.
)
Left
chain
Slide33Running Time of Jarvis’s March
Let
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
.
Comparison between two polar angles can be done
using cross product.
Thus
time in total.