1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)

Slides:



Advertisements
Similar presentations
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.
Advertisements

Lecture 3: Parallel Algorithm Design
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
algorithms and data structures
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
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.
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.
CS4413 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.
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.
Computational Geometry
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
Lecture 3: Reduce to known problem Convex Hull (section 33.3 of CLRS). Suppose we have a bunch of points in the plane, given by their x and y coordinates.
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
Algorithms and Data Structures Lecture 13. Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull.
5/17/2015 1:32 AMConvex Hull1 obstacle start end.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
1.4 Exercises (cont.) Definiton: A set S of points is said to be affinely (convex) independent if no point of S is an affine combination of the others.
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
Algorithm 1. (Convex Hull) - Pseudo code - Input. A set of points in the plane. Output. A list containing the vertices of Conv ( P). 1. Sort the points.
Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute.
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 2 Chapter 2: Polygon Partitioning.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring.
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
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.
5 -1 Chapter 5 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
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.
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.
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
Computational Geometry 2D Convex Hulls
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
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 Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is.
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last time Several convex hull algorithms. Lower bound of O(n log n) –O(n log h) for output sensitive.
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.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Lecture 3: Parallel Algorithm Design
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Computational Geometry Capter:1-2.1
Convex Sets & Concave Sets
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
CMPS 3130/6130: Computational Geometry Spring 2017
CMPS 3120: Computational Geometry Spring 2013
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Introduction to Algorithms
Presentation transcript:

1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)

2 Outline Definitions of CH Algorithms for CH Analysis of algorithms

3 Convex Hull Definition of convexity Convex hull of a point set S, CH(S) Smallest convex set containing S Intersection of all convex sets containing S 凸包 (Convex Hull)

4 Convex Hull Why computing CH? Many reasons; e.g., faster collision detection How to compute CH? Good solutions come from:  A thorough understanding of the geometric properties of the problem  Proper application of algorithmic techniques and data structures

5 General Steps Sketch your problem in general position Observe the desired output and reason about the possible steps to get to the goal Check for degeneracy Time/resource complexity General case Best/worst cases

6 Computing CH … of a finite set P of n points in 2D Geometric intuition: Rubberband analogy Representation: Input: point set Output: CH(P): CW- ordered point set

7 Observation Def: convex edgesIdea: Search through all pairs of points for convex edges Form a loop

8 Naïve Algorithm You can add a break here if you like …

9 Analysis of Naïve Algorithm Assumption: points are in general position (usually this is done first to simplify the code) (consider the degenerate cases later) How to compute “lie to the left of directed line”? Complexity analysis: O(n 3 ) (n 2 –n)/2 pairs, each with n–2 other points to examine High complexity due to: simply translate geometric insight into an algorithm in a brute-force manner

10 Considering Degeneracy Collinearity: Modify the test to “all points to the right, or on the line” Does this solve the problem?!

11 Degenerate Case (cont) Consider numerical inaccuracy Two possibilities:

12 Jarvis’ March (Gift Wrapping) A modification of naïve algorithm Start at some extreme point, which is guaranteed to be on the hull. At each step, test each of the points, and find the one which makes the smallest right-hand turn. That point has to be the next one on the hull. The final CW loop is the CH.

13 Jarvis’ March (cont) Complexity Crude count: O(n 2 ) Output sensitive O(nh), h:# of segments on the hull Worst case

14 A Better Algorithm Sort by x-coord The extreme points must be on the CH Goal: in 2 linked lists Upper hull: p1 to pn Lower hull: pn to p1 Idea: In CW manner, always making right turns If fail to turn right, delete previous point until the turn is correct.

15

16 Step-by-step [1,2]

17 Step-by-step [1,2,3]

18 Step-by-step [1,3]

19 Step-by-step [1,3,4]

20 Step-by-step [1,3,4,5]

21 Step-by-step [1,3,5]

22 Step-by-step [1,3,5,6]

23 Step-by-step [1,3,5,6,7]

24 Step-by-step [1,3,5,7]

25 Step-by-step [1,3,7]

26 Step-by-step [1,3,7,8]

27 Step-by-step [1,3,7,8,9]

28 Step-by-step [1,3,7,9] Upper hull completed

29 Algorithm (cont) This is a variation of Graham Scan Proof of correctness: p.8 Complexity analysis: O(n log n) Lexicographical sorting of points: O(n log n) Computation of lower hull: O(n)  Consider the for and while

30 Consider Degeneracy Again … Effects on sorting Lexico. ordering Effects on making turns…

31 Other Version of Graham Scan 1. Find an extreme point. This point will be the pivot, is guaranteed to be on the hull, and is chosen to be the point with smallest y coordinate. 2. Sort the points in order of increasing angle about the pivot. We end up with a star-shaped polygon (one in which one special point, in this case the pivot, can "see" the whole polygon). 3. Build the hull, by marching around the star-shaped poly, adding edges when we make a left turn, and back-tracking when we make a right turn.

32 Graham Scan (ver2) Also handles collinearity

33 Incremental Algorithm Suitable for dynamic CGeom and 3D hull If p n  CH n-1, CH n =CH n-1 Else Find two tangents, update CH n

Incremental Algorithm Input: a set of points P in 2D Output: a list L containing the points of CH(P) in CCW order 1. Take first three points of P to form a triangle 2. For i = 4 to n If (p i is in CH i-1 ) do nothing Else  FindTangent (p i, CH i-1 )  t1, t2  Replace the items {t2 … t1} in L by {t2, p i, t1} 34 t1 t2 CH i-1 pipi

FindTangent (p, CH) (Go through all points in CH circularly) For each point p i If XOR (p is left_or_on (p i-1,p i ), p is left_or_on(p i,p i+1 )) Mark p i as the tangent point (There will be two tangent points) Determine t1, t2 35 t1 t2 CH i-1 pipi

36 Incremental Algorithm (cont) Finding Tangents … Analysis

37 Quick Hull Discard points in the extreme quadrilateral

38 Quick Hull (cont) Time complexity: Find extreme point c: O(n) Cost of recursive call:  T(n) = O(n) + T(|A|) + T(|B|) Best case: |A| = |B| = n/2  T(n) = 2T(n/2) + O(n); T(n) = O(n log n) Worst case: |A| = 1, |B| = n-1  T(n) = T(n-1) + O(n); T(n) = O(n 2 )

39 Divide and Conquer Algorithm Computing 3D hull: Graham scan (probably not ∵ angle sort ) Preparata and Hong (1977) T(n) = 2T(n/2) + O(n); T(n) = O(n log n) a-1 & a+1 at left side of ab b-1 & b+1 at left side of ab

40 Extend to 3D

41 Floating Point Inaccuracies Handled by Interval arithmetic Exact (rational) arithmetic

42 Interval arithmetic Ref:

43 Exact Math Rational arithmetic (never floating point) In[6]:= 1/12 - 7/9 + 31/36 Out[6]= - 1/6 The Exact Arithmetic Competition: Level 0 Tests Ref: XRXR

44 Exercise From this applet, develop a Graham scan algorithm that returns a CW-ordered convex hullapplet Express the algorithm in pseudocode. Make sure it works for general position and degenerate cases (shown right) Run your example on test cases (general position and degeneracies) Explain the correctness and time complexity of divide-and-conquer algorithm

45

46 More reference on the web.