This preview shows page 1. Sign up to view the full content.
Unformatted text preview: UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry
Prof. Karen Daniels
Spring, 2010 Spring Lecture 3 O'Rourke Chapter 3: p 2D Convex Hulls
Thursday, 2/18/10 Chapter 3 Ch t
2D C Convex H ll Hulls Definitions Gift Wrapping Graham Scan QuickHull Incremental Divide d Divide andConquer Di id andC Lower Bound in (nlgn) Convexity & Convex Hulls
source: O'Rourke, Computational Geometry in C A convex combination of points x1, ..., xk is a sum of the form 1x1+...+ kxk where i 0 i and 1 + L + k = 1
Convex hull of a set of points is the set of all convex combinations of points in the set. i t i th t
We will construct boundary of convex hull. nonconvex polygon source: 91.503 textbook Cormen et al. convex hull of a point set Naive Algorithms for Extreme Points
Algorithm: Algorithm: INTERIOR POINTS for each i do for each j = i do for each k = j = i do for f each L = k = j = i d h do if pL in triangle(pi, pj, pk) then pL is nonextreme O(n4) This is essentially de Berg et al.'s SLOWCONVEXHULL in their Chapter 1. al.'s Algorithm: EXTREME EDGES Algorithm: g for each i do for each j = i do for each k = j = i do if pk is not (left or on) (pi, pj) then (pi , pj) is not extreme O(n3) source: O'Rourke, Computational Geometry in C Algorithms: 2D Gift Wrapping
Use one extreme edge as an anchor for finding the next g Algorithm: Algorithm: GIFT WRAPPING index of the lowest point i0 i i0 repeat for each j = i Compute counterclockwise angle from previous hull edge k index of point with smallest Output (pi , pk) as a hull edge i k until i = i0 O(n2) source: O'Rourke, Computational Geometry in C Gift Wrapping source: 91.503 textbook Cormen et al. 33.9 Output Sensitivity: O(n2) runtime is actually O(nh) Sensitivity: runwhere h is the number of vertices of the convex hull. Algorithms: 2D QuickHull
Concentrate on points close to hull boundary Named f similarity to N d for i il it t Quicksort
a b A c
finds one of upper or lower hull Algorithm: Algorithm: QUICK HULL function QuickHull(a,b,S) if S = 0 return() else c index of point with max distance from ab A points strictly right of (a c) (a,c) B points strictly right of (c,b) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) O(n2) source: O'Rourke, Computational Geometry in C Graham's Algorithm
source: O'Rourke, Computational Geometry in C Points sorted angularly provide "star"starshaped" starting point Prevent "dents" as you go via dents convexity testing
p0 Algorithm: Algorithm: GRAHAM SCAN, Version B Find rightmost lowest point; label it p0. Sort all other points angularly about p0. In case of tie, delete point(s) closer to p0. Stack S (p1, p0) = (pt, pt1); t indexes top i 2 while i < n do if pi is strictly left of pt1pt then Push(pi, S) and set i i +1 else Pop(S) "multipop" O(nlgn) Graham Scan source: 91.503 textbook Cormen et al. Graham Scan 33.7 source: 91.503 textbook Cormen et al. Graham Scan 33.7 source: 91.503 textbook Cormen et al. Graham Scan source: 91.503 textbook Cormen et al. Graham Scan source: 91.503 textbook Cormen et al. Algorithms: 2D Incremental
source: O'Rourke, Computational Geometry in C Add points, one at a time i i
update hull for each new point Key step becomes adding a single point to an existing hull.
Find 2 tangents g
Results of 2 consecutive LEFT tests differ Idea can be extended to 3D.
This is essentially de Berg et al.'s CONVEXHULL in their Chapter 1. al.'s Algorithm: Algorithm: INCREMENTAL ALGORITHM ConvexHull{p0 , p1 , p2 } {p Let H2 for k 3 to n  1 do ConvexHull{ Hk1 U pk } Hk O(n2)
can be improved to O(nlgn) source: O'Rourke, Computational Geometry in C Algorithms: 2D Divide and Conquer DivideandConquer
B DivideandDivideandConquer in a geometric q g setting O(n) merge step is the challenge
Find Fi d upper and l d lower tangents t t Lower tangent: find rightmost pt of A & leftmost pt of B; then "walk it downwards" A Idea Id can be extended to 3D. b t d d t 3D
Algorithm: DIVIDEandAlgorithm: DIVIDEandCONQUER Sort points by x coordinate Divide points into 2 sets A and B: A contains left n/2 points B contains right n/2 points t i i ht /2 i t Compute ConvexHull(A) and ConvexHull(B) recursively Merge ConvexHull(A) and ConvexHull(B) O(nlgn) Lower Bound of (nlgn)
source: O'Rourke, Computational Geometry in C WorstWorstcase time to find convex hull of n points in algebraic decision tree model is in (nlgn) Proof uses sorting reduction:
Given unsorted list of n numbers: (x1,x2 ,..., xn) Form unsorted set of points: (xi, xi2) f each xi F t d t f i t ( for h Convex hull of points produces sorted list! list!
Parabola: every p y point is on convex hull Reduction is O(n) (which is in o(nlgn)) Finding convex hull of n points is therefore at least as hard as sorting n points, so worstcase points worsttime is in (nlgn) Parabola for sorting 2,1,3
How does this relate to outputsensitive results? output ...
View Full
Document
 Spring '10
 DANIELS
 Algorithms

Click to edit the document details