1 / 15

Convex Hulls

Convex Hulls. Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann. Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg. Overview. Computing the convex hull The Naïve approach Graham Scan

wing-carson
Download Presentation

Convex Hulls

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. Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

  2. Overview • Computing the convex hull • The Naïve approach • Graham Scan • Lower bound • Design, analysis, implementation Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  3. p p pq pq q q Convex Hulls • Subset of S of the plane is convex, if for all pairs p,q in Sthe line segment pq is completely contained in S. • The Convex HullCH(S) is the smallest convex set, which contains S. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  4. Convex Hull of a Set of Points in the Plane • The convex hull of a set P of points is the unique convex polygon whose vertices are points of P and which contains all points from P. Rubber band experiment Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  5. Polygons • A polygon P is a closed, connected sequence of line segments. • A polygon is simple, if it does not intersect itself. • A simple polygon is convex, if the enclosed area is convex. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  6. q p Computing the Convex Hull • Right rule: The line segment pq is part of the CH(P) iff all points of P-{p,q} lie to the right of the line through p and q. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  7. E= • for all (p, q) from PxP with p q • valid = true • for all r in P with r p and rq • if r lies to the left of the directed line from p to q • valid = false • if valid then for E = E  { pq } • Construct CH(P) as a list of nodes fromE • Run time: O(n³) Naïve Procedure Input: A set Pof points in the plane Output: Convex Hull CH(P) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  8. Degenerate Cases 1. Linear dependency: more points are on a line. Solution: extended definition by cases. 2. Rounding errors due computer arithmetic (floats). Solution: symbolic computation, interval arithmetic. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  9. Incremental approach: Given: Upper hull for p1,...,pi-1 Compute: Upper hull for p1,...,pi An Incremental Algorithm Upper Hull Partitioning of the problem: Lower Hull z X s X X Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  10. Computation of UH (Graham Scan) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  11. Fast Computation of the Convex Hull Input/output:see " naive procedure " Sort Paccording to x-Coordinates LU={p1, p2 } fori = 3 to n LU = LU { pi } while LU contains more than 2 points and the last 3 points in LU do not make a right turn do delete the middle of last 3 points LL={pn, pn-1 } fori = n-2 to 1 LL = LL { pi } whileLL contains more than 2 points and the last 3 points in LL do not make a right turn do delete the middle of last 3 points delete first and last point in LL CH(P) = LU  LL Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  12. Runtime Theorem: The fast algorithm for computing the convex hull (Graham Scan) can be carried out in time O(n log n). Proof: (for UH only) Sorting n points in lexicographic order takes time O(n log n). Execution of the for-loop takes time O(n). Total number of deletions carried out in all executions of the while loop takes time O(n). Total runtime for computing UH is O(n log n) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  13. pi+1 V pi Correctness • Proof: for Upper Hull by induction: • {p1, p2 } is a correct UH for a set of 2 points. • Assume: { p1,...,pi } is a correct UH for i points and consider pi+1 By induction a too high point may lie only in the slab V. This, however, contradicts the lexicographical order of points! Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  14. x1 x2 ... xn Lower Bound Reduction of the sorting problem to the computation of the convex hull. 1.x1, ... ,xn (x1, x1²), ... ,(xn,,xn²)O(n) 2. Construct the convex hull for these points 3. Output the points in (counter-)clockwise order Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  15. 1. Design the algorithm and ignore all special cases. 2. Handle all special cases and degeneracies. 3. Implementation: Computing geometrical objects: best possibleDecisions (e.g. comparison operations): suppose exact (correct) results Support: Libraries:LEDA, CGAL Visualizations:VEGA Design, Analysis & Implementation Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

More Related