C o m p u t i n g C O N V E X H U L L S. Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull.

Slides:



Advertisements
Similar presentations
Geometry Introduction
Advertisements

2/9/06CS 3343 Analysis of Algorithms1 Convex Hull  Given a set of pins on a pinboard  And a rubber band around them  How does the rubber band look when.
Jarvis March Graham Scan Chan’s Algorithm
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
CS16: Introduction to Data Structures & Algorithms
C o m p u t i n g C O N V E X H U L L S by Kok Lim Low 10 Nov 1998 COMP Presentation.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
The Divide-and-Conquer Strategy
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Ruslana Mys Delaunay Triangulation Delaunay Triangulation (DT)  Introduction  Delaunay-Voronoi based method  Algorithms to compute the convex hull 
Theory of Algorithms: Divide and Conquer
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org 6 Ack : Carola Wenk nad Dr. Thomas Ottmann tutorials.
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
By Groysman Maxim. Let S be a set of sites in the plane. Each point in the plane is influenced by each point of S. We would like to decompose the plane.
Convex Hulls in 3-space Jason C. Yang.
Convex Sets & Concave Sets A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R.
1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)
Computational Geometry
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
Informal Definition : Let S is set of nails sticking out from a board. the convex hull can be visualized as the shape formed by a tight rubber band that.
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 Lecture 2 Polygon Partitioning Thursday,
Computational Geometry -- Voronoi Diagram
UMass Lowell Computer Science Graduate Algorithms Prof. Karen Daniels Spring, 2005 Computational Geometry Overview from Cormen, et al. Chapter 33.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Chapter 4: 3D Convex Hulls Friday, 2/9/07.
Computational Geometry Overview from Cormen, et al. Chapter 33
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Tuesday, 5/7/02 Computational Geometry Chapter 33.
Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute.
UMass Lowell Computer Science Graduate Algorithms Prof. Karen Daniels Spring, 2009 Computational Geometry Overview from Cormen, et al. Chapter 33.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Chapter 4: 3D Convex Hulls Monday, 2/23/04.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 3 Chapter 4: 3D Convex Hulls Chapter.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
Convex Hull. What is the Convex Hull? Imagine a set of points on a board with a nail hammered into each point. Now stretch a rubber band over all the.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
Computational Geometry 2D Convex Hulls Joseph S. B. Mitchell Stony Brook University Chapter 2: Devadoss-O’Rourke.
Fundamental Data Structures and Algorithms Klaus Sutner April 27, 2004 Computational Geometry.
Fundamental Data Structures and Algorithms Margaret Reid-Miller 27 April 2004 Computational Geometry.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
1 / 41 Convex Hulls in 3-space Jason C. Yang. 2 / 41 Problem Statement Given P: set of n points in 3-space Return: –Convex hull of P: CH (P) –Smallest.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday,
UNC Chapel Hill M. C. Lin Delaunay Triangulations Reading: Chapter 9 of the Textbook Driving Applications –Height Interpolation –Constrained Triangulation.
Computational Geometry 2D Convex Hulls
A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R. Otherwise, it is called concave.
COMPUTATIONAL GEOMETRY AND MATRIX MULTIPLICATION Mohammed Zeeshan Farooqui Minhaj Uddin.
Convex Sets & Concave Sets A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Convex hulls in 3D Maciej Kot. Finding convex hull Given a set of points, find a convex hull that contains all of them and is minimal.
An Introduction to Computational Geometry: Arrangements and Duality Joseph S. B. Mitchell Stony Brook University Some images from [O’Rourke, Computational.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Polygon Triangulation
CMPS 3130/6130 Computational Geometry Spring 2017
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Convex Sets & Concave Sets
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Computational Geometry
CMPS 3120: Computational Geometry Spring 2013
Introduction to Algorithms
Presentation transcript:

c o m p u t i n g C O N V E X H U L L S

Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull Graham Scan Incremental Divide and Conquer By Delaunay Triangulation & Voronoi Diagram (later)

Definitions and Properties –Intersection of all convex sets containing P –Smallest convex set containing P –Intersection of all half-planes containing P –Union of all triangles formed by points of P rubber band

Definitions and Properties –Smallest convex polygon containing P –All vertices of hull are some points of P –NOTE: convex hull is the closed solid region, not just the boundary extreme point not extreme point always unique

Brute-Force Approach Determine extreme edges for each pair of points p,q  P do if all other points lie on one side of line passing thru p and q then keep edge (p, q) p q

Brute-Force Approach Next, sort edges in counterclockwise order –we want output in counterclockwise Running time: O(n 3 ) –bad but not the worst yet

Gift Wrapping p  the lowest point p 0 repeat for each q  P and q  p do compute counterclockwise angle  from previous hull edge let r be the point with smallest  output (p, r) as a hull edge p  r until p = p 0 p 

Gift Wrapping First suggested by Chand and Kapur (1970) Worst-case time: O(n 2 ) Output-sensitive time: O(nk) –where k is the # of vertices of hull Can be extended to higher dimension –was the primary algorithm for higher dimensions for quite some time

Graham Scan By Graham (1972) First algorithm to achieve optimal running time Uses angular sweep

Graham Scan Animated demo – java/algo/solutions/lesson12/ConvexHull.htmlhttp:// java/algo/solutions/lesson12/ConvexHull.html

Graham Scan Find rightmost lowest point p 0 Sort all other points angularly about p 0, break ties in favor of closeness to p 0 ; label them p 1, p 2,..., p n-1 Stack S = (p n-1, p 0 ) = (p t-1, p t ); t indexes top i  1 while i < n do if p i is strictly left of (p t-1, p t ) then Push(S, i); i++ else Pop(S)

Graham Scan Running time: O(n lg n) –the whole sweep takes O(n) only because each point can be pushed or popped at most once –O(n lg n) due to sorting of angles No obvious extension to higher dimensions

Lower Bound Is  (n lg n) the lower bound running time of any 2D convex hull algorithm? Yes –Proven by Yao (1981) using decision tree Can be proven by reducing sorting to finding convex hull –Sorting has lower bound  (n lg n)

Lower Bound We can use a convex hull algorithm to sort (Shamos, 1978) for each input number x do create a 2D point (x, x 2 ) Construct a hull for these points Find the lowest point on the hull and follow the vertices of the hull

Lower Bound If we can compute hull faster than  (n lg n) then we can sort faster than  (n lg n). Impossible!

QuickHull Suggested by researchers in late 1970s Dubbed the “QuickHull” algorithm by Preparata and Shamos (1985) because of similarity to QuickSort Works by recursively discarding points Very commonly implemented, just like QuickSort –Qhull

QuickHull Animated demo – a b a b c A B

QuickHull function QuickHull(a, b, S) if S = {a, b} then return {a, b} else c  point furthest from edge (a, b) A  points right of (a, c) B  points right of (c, b) return QuickHull(a, c, A) concatenate with QuickHull(c, b, B) Worst-case time: O(n 2 ) –when “partitions” are very unbalanced Best- and average-case time: O(n lg n)

Divide & Conquer First applied to convex hull problem by Preparata and Hong (1977) The only technique known to extend to 3D and still achieve O(n lg n) time complexity

Divide & Conquer Sort the points from left to right Let A be the leftmost  n/2  points Let B be the rightmost  n/2  points Compute convex hulls H(A) and H(B) Compute H(A  B) by merging H(A) and H(B) Merging is tricky, but can be done in linear time

Divide & Conquer Need to find the upper and lower tangents They can be found in linear time AB lower tangent upper tangent

Divide & Conquer Find lower tangent AB lower tangent

Divide & Conquer Find lower tangent Let a be the rightmost point of A Let b be the leftmost point of B while ab not lower tangent of both A and B do while ab not lower tangent to A do a  next clockwise point on H(A) while ab not lower tangent to B do b  next counterclockwise point on H(B)

Incremental Algorithm Basic idea H 2  conv{ p 0, p 1, p 2 } for k  3 to n - 1 do H k  conv{ H k-1  p k } Two cases to consider –case 1: p k  H k-1 need not update hull –case 2: p k  H k-1 need to update hull

Incremental Algorithm When p k  H k-1 pkpk H k-1

Incremental Algorithm Requires O(n 2 ) time but points can be dynamically added to P Can be done in randomized expected time O(n lg n) Can be improved to worst-case O(n lg n) (Edelsbrunner, 1987) Sort points from left to right H 2  conv2{ p 0, p 1, p 2 } for k  3 to n - 1 do H k  conv2{ H k-1  p k }

Incremental Algorithm Always p k  H k-1 pkpk H k-1 p k-1 upper hull lower hull

By Delaunay Triangulation & Voronoi Diagram

By Delaunay Triangulation Compute Delaunay triangulation of P p  the rightmost lowest point p 0 in P repeat for each point adjacent to p do compute counterclockwise angle  from previous hull edge let q be the point with smallest  output (p, q) as a hull edge p  q until p = p 0

By Delaunay Triangulation Delaunay triangulation can be computed in O(n lg n) time The rest takes O(n) time Therefore, total time is O(n lg n) Can use Voronoi diagram similarly since it is the dual of Delaunay triangulation

3D CONVEX HULLS

3D Convex Hulls 3D convex hull is the smallest convex polyhedron or 3-polytope enclosing P Complexity of 3D convex hull –Euler’s formula: V  E + F = 2 –F and E are O(n) where n = V

3D Gift Wrapping Basic idea Let partial hull H  a triangle on the hull for each edge e on the boundary of H do let F  H be the face bounded by e let  be the plane containing F “bent”  over e toward the other points until the first point p is encountered H  H  {triangle formed by e and p}

3D Gift Wrapping Worst-case time complexity: O(n 2 ) Output-sensitive time: O(nF) –where F is the number of faces on the hull

3D QuickHull Similar to the 2D algorithm, but begins with a 8-face polytope leftmost topmost bottommost rightmost frontmost

3D QuickHull Worst-case time: O(n 2 ) –when “partitions” are very unbalanced Best- and average-case time: O(n lg n)

3D Divide & Conquer before after

3D Divide & Conquer Same paradigm as 2D algorithm Sort the points from left to right Let A be the leftmost  n/2  points Let B be the rightmost  n/2  points Compute convex hulls H(A) and H(B) Compute H(A  B) by merging H(A) and H(B) Need to merge in O(n) time in order to achieve overall O(n lg n) time

3D Divide & Conquer Merging (basic idea) –find faces joining H(A) and H(B) –discard hidden faces find joining faces

3D Incremental Algorithm horizon Animated demo – students/bglazer/javaHull/hull.htmlhttp://imagery.mit.edu/imagery3/6.838/S98/ students/bglazer/javaHull/hull.html

3D Incremental Algorithm Initialize H 4 to tetrahedron (p 0, p 1, p 2, p 3 ) for i  4 to n-1 do for each face f of H i-1 do compute volume of tetrahedron formed by f and p i mark f visible iff volume < 0 if no faces are visible then discard p i (it is inside H i-1 ) else for each horizon edge e of H i-1 do construct cone face determined by e and p for each visible face f do delete f update H i

3D Incremental Algorithm Requires O(n 2 ) time Can be improved to randomized expected time O(n lg n)

Convex Hulls in Higher Dimensions Unfortunately, convex hull in d dimensions can have  (n  d/2  ) facets (proved by Klee, 1980) –therefore, 4D hull can have quadratic size No O(n lg n) algorithm possible for d > 3 These approaches can extend to d > 3 –gift wrapping –QuickHull –divide & conquer –incremental

References Main reference –“Computational Geometry in C” by Joseph O’Rourke, 1994 Other references –our textbook “Computational Geometry - An Introduction” by Preparata and Shamos, 1985 – “Computational Geometry: Algorithms and Applications” by M. de Berg, M. van Kreveld, M. Overmars, and O. Schwarzkopf, –“Introduction to Algorithms” by Cormen, Leiserson and Rivest, 1990