1 / 21

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007. Lecture 3 Chapter 3: 2D Convex Hulls Friday, 2/9/07. Chapter 3. Definitions Gift Wrapping Graham Scan QuickHull Incremental Divide-and-Conquer Lower Bound in W (nlgn).

dian
Télécharger la présentation

UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UMass Lowell Computer Science 91.504Advanced AlgorithmsComputational GeometryProf. Karen DanielsSpring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday, 2/9/07

  2. Chapter 3 Definitions Gift Wrapping Graham Scan QuickHull Incremental Divide-and-Conquer Lower Bound in W(nlgn) 2D Convex Hulls

  3. nonconvex polygon convex hull of a point set Convexity & Convex Hulls source: O’Rourke, Computational Geometry in C • A convex combination of points x1, ..., xk is a sum of the form a1x1+...+ akxk where • Convex hull of a set of points is the set of all convex combinations of points in the set. We will construct boundary of convex hull. source: 91.503 textbook Cormen et al.

  4. Algorithm: INTERIOR POINTS for each i do for each j = i do for each k = j = i do for each L = k = j = i do if pL in triangle(pi, pj, pk) then pL is nonextreme Algorithm: EXTREME EDGES 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) Naive Algorithms for Extreme Points O(n4) source: O’Rourke, Computational Geometry in C

  5. q Algorithms: 2D Gift Wrapping • Use one extreme edge as an anchor for finding the next Algorithm: GIFT WRAPPING i0 index of the lowest point i i0 repeat for each j = i Compute counterclockwise angle q from previous hull edge k index of point with smallest q Output (pi , pk) as a hull edge i k until i = i0 O(n2) source: O’Rourke, Computational Geometry in C

  6. Gift Wrapping source: 91.503 textbook Cormen et al. 33.9 Output Sensitivity: O(n2) run-time is actually O(nh) where h is the number of vertices of the convex hull.

  7. Algorithms: 3D Gift Wrapping O(n2) time [output sensitive: O(nF) for F faces on hull] CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

  8. 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) B points strictly right of (c,b) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) O(n2) Algorithms: 2D QuickHull • Concentrate on points close to hull boundary • Named for similarity to Quicksort a b A c finds one of upper or lower hull source: O’Rourke, Computational Geometry in C

  9. Algorithms: 3D QuickHull CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

  10. Algorithms for Convex Hull boundary is intersection of hyperplanes, so worst-case combinatorial size (not necessarily running time) complexity is in: Qhull: http://www.qhull.org

  11. 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, pt-1); t indexes top i 2 while i < n do if pi is strictly left of pt-1pt then Push(pi, S) and set i i +1 else Pop(S) q O(nlgn) Graham’s Algorithm source: O’Rourke, Computational Geometry in C • Points sorted angularly provide “star-shaped” starting point • Prevent “dents” as you go via convexity testing p0 “multipop”

  12. Graham Scan source: 91.503 textbook Cormen et al.

  13. Graham Scan 33.7 source: 91.503 textbook Cormen et al.

  14. Graham Scan 33.7 source: 91.503 textbook Cormen et al.

  15. Graham Scan source: 91.503 textbook Cormen et al.

  16. Graham Scan source: 91.503 textbook Cormen et al.

  17. Algorithms: 2D Incremental source: O’Rourke, Computational Geometry in C • Add points, one at a time • update hull for each new point • Key step becomes adding a single point to an existing hull. • Find 2 tangents • Results of 2 consecutive LEFT tests differ • Idea can be extended to 3D. Algorithm: INCREMENTAL ALGORITHM Let H2 ConvexHull{p0 , p1 , p2 } for k 3 to n - 1 do Hk ConvexHull{ Hk-1 U pk } O(n2) can be improved to O(nlgn)

  18. Algorithms: 3D Incremental O(n2) time CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

  19. Algorithms:2D Divide-and-Conquer source: O’Rourke, Computational Geometry in C • Divide-and-Conquer in a geometric setting • O(n) merge step is the challenge • Find upper and lower tangents • Lower tangent: find rightmost pt of A & leftmost pt of B; then “walk it downwards” • Idea can be extended to 3D. B A Algorithm: DIVIDE-and-CONQUER 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 Compute ConvexHull(A) and ConvexHull(B) recursively Merge ConvexHull(A) and ConvexHull(B) O(nlgn)

  20. Algorithms:3D Divide and Conquer O(n log n) time ! CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

  21. Lower Bound of O(nlgn) source: O’Rourke, Computational Geometry in C • Worst-case time to find convex hull of n points in algebraic decision tree model is in W(nlgn) • Proof uses sorting reduction: • Given unsorted list of n numbers: (x1,x2 ,…, xn) • Form unsorted set of points: (xi, xi2) for each xi • Convex hull of points produces sorted list! • Parabola: every 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 worst-case time is in W(nlgn) Parabola for sorting 2,1,3

More Related