Convex Sets & Concave Sets Otherwise, it is called concave. Convex Concave
An Example 4 1 2 3 Regions 1 & 2: convex Regions 3 & 4: concave
Convex Hull Rubber band
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.
The Convex Hull Problem Example (direction of traversal about the outward axis with the interior on the left)
Edges of a Convex Hull q p
A Slow Convex Hull Algorithm
Floating Arithmetic is not Exact! Nearly colinear points p, q, r. q r p 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.
Polar Angle polar angle p
Graham Scan This node will be a vertex of the convex hull.
Tie Breaking (1)
Sorting by Polar Angle Labels are in the polar angle order.
No Polar Angle Evaluation if
Tie Breaking (2) if No square roots. Use dot product! and
Point Elimination Remove the rest since they cannot possibly be the hull vertices. furtherest remove
Stack Initialization
Finish S
Graham’s Scan finish start
The Graham Scan Algorithm
Running time #operations Finding Why? time / operation total
Proof of Correctness Claim 1 Each point popped from stack S is not a vertex of CH(P). Proof
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 The invariant still holds.
Correctness of Graham’s Scan
Jarvis’ March A “package wrapping” technique Right chain Left chain (lowest point)
Running Time of Jarvis’s March Comparison between two polar angles can be done using cross product.