Convex Hull 1/1/2019 10:28 AM Convex Hull obstacle start end.

Slides:



Advertisements
Similar presentations
Polygon Triangulation
Advertisements

Computational Geometry
Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.
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.
Lecture 3: Parallel Algorithm Design
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
algorithms and data structures
Brute-Force Triangulation
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
CS16: Introduction to Data Structures & Algorithms
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.
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.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
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
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]
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Computational Geometry -- Voronoi Diagram
6/2/ :35 AMIncremental Convex Hull1 q w u e zt.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
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.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
Fundamental Data Structures and Algorithms Klaus Sutner April 27, 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.
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.
Polygon Triangulation
CMPS 3130/6130 Computational Geometry Spring 2017
3. Polygon Triangulation
Computational Geometry
Lecture 3: Parallel Algorithm Design
Computer Graphics Filling.
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
Fill Area Algorithms Jan
Convex Hull.
Query Processing in Databases Dr. M. Gavrilova
Lecture 12 Algorithm Analysis
Algorithm design techniques Dr. M. Gavrilova
Red-Black Trees v z /20/2018 7:59 AM Red-Black Trees
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Computational Geometry Capter:1-2.1
Geometry.
Convex Sets & Concave Sets
I. The Problem of Molding
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
SIMD, Associative, and Multi-Associative Computing
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Introduction to Algorithms
(2,4) Trees /6/ :26 AM (2,4) Trees (2,4) Trees
Lecture 12 Algorithm Analysis
Computational Geometry Algorithms
Geometry.
Algorithms and Data Structures Lecture XIV
Presentation transcript:

Convex Hull 1/1/2019 10:28 AM Convex Hull obstacle start end

Outline and Reading Convex hull (§12.5.2) Orientation (§12.5.1-2) 1/1/2019 10:28 AM Outline and Reading Convex hull (§12.5.2) Orientation (§12.5.1-2) Sorting by angle (§12.5.5) Graham scan (§12.5.5) Analysis (§12.5.5)

Convex Hull 1/1/2019 10:28 AM Convex Polygon A convex polygon is a nonintersecting polygon whose internal angles are all convex (i.e., less than p) In a convex polygon, a segment joining two vertices of the polygon lies entirely inside the polygon convex nonconvex

Convex Hull 1/1/2019 10:28 AM Convex Hull The convex hull of a set of points is the smallest convex polygon containing the points Think of a rubber band snapping around the points

Special Cases The convex hull is a segment The convex hull is a point 1/1/2019 10:28 AM Special Cases The convex hull is a segment Two points All the points are collinear The convex hull is a point there is one point All the points are coincident

Applications Motion planning Geometric algorithms obstacle start end Convex Hull 1/1/2019 10:28 AM Applications Motion planning Find an optimal route that avoids obstacles for a robot Geometric algorithms Convex hull is like a two-dimensional sorting obstacle start end

Computing the Convex Hull 1/1/2019 10:28 AM Computing the Convex Hull The following method computes the convex hull of a set of points Phase 1: Find the lowest point (anchor point) Phase 2: Form a nonintersecting polygon by sorting the points counterclockwise around the anchor point Phase 3: While the polygon has a nonconvex vertex, remove it

Orientation b c CW a c b CCW a c b COLL a Convex Hull 1/1/2019 10:28 AM Orientation The orientation of three points in the plane is clockwise, counterclockwise, or collinear orientation(a, b, c) clockwise (CW, right turn) counterclockwise (CCW, left turn) collinear (COLL, no turn) The orientation of three points is characterized by the sign of the determinant D(a, b, c), whose absolute value is twice the area of the triangle with vertices a, b and c a b c CW c b CCW a c b a COLL

Convex Hull 1/1/2019 10:28 AM Sorting by Angle Computing angles from coordinates is complex and leads to numerical inaccuracy We can sort a set of points by angle with respect to the anchor point a using a comparator based on the orientation function b < c  orientation(a, b, c) = CCW b = c  orientation(a, b, c) = COLL b > c  orientation(a, b, c) = CW CCW COLL CW c c b b b c a a a

Removing Nonconvex Vertices Convex Hull 1/1/2019 10:28 AM Removing Nonconvex Vertices Testing whether a vertex is convex can be done using the orientation function Let p, q and r be three consecutive vertices of a polygon, in counterclockwise order q convex  orientation(p, q, r) = CCW q nonconvex  orientation(p, q, r) = CW or COLL r r q q p p

Graham Scan p q r H p q r H p q r H for each vertex r of the polygon Convex Hull 1/1/2019 10:28 AM Graham Scan The Graham scan is a systematic procedure for removing nonconvex vertices from a polygon The polygon is traversed counterclockwise and a sequence H of vertices is maintained for each vertex r of the polygon Let q and p be the last and second last vertex of H while orientation(p, q, r) = CW or COLL remove q from H q  p p  vertex preceding p in H Add r to the end of H p q r H p q r H p q r H

Convex Hull 1/1/2019 10:28 AM Analysis Computing the convex hull of a set of points takes O(n log n) time Finding the anchor point takes O(n) time Sorting the points counterclockwise around the anchor point takes O(n log n) time Use the orientation comparator and any sorting algorithm that runs in O(n log n) time (e.g., heap-sort or merge-sort) The Graham scan takes O(n) time Each point is inserted once in sequence H Each vertex is removed at most once from sequence H See pages 584-585 for a Java implementation of this algorithm.

Incremental Convex Hull 1/1/2019 10:28 AM Incremental Convex Hull q w u e z t

Outline and Reading Point location Incremental convex hull Problem 1/1/2019 10:28 AM Outline and Reading Point location Problem Data structure Incremental convex hull Insertion algorithm Analysis

Convex Hull 1/1/2019 10:28 AM Point Location TH Given a convex polygon P, a point location query locate(q) determines whether a query point q is inside (IN), outside (OUT), or on the boundary (ON) of P An efficient data structure for point location stores the top and bottom chains of P in two binary search trees, TL and TH of logarithmic height An internal node stores a pair (x (v), v) where v is a vertex and x (v) is its x-coordinate An external node represents an edge or an empty half-plane P TL

Point Location (cont.) TH eH P q vL TL Convex Hull 1/1/2019 10:28 AM Point Location (cont.) TH To perform locate(q), we search for x(q) in TL and TH to find Edge eL or vertex vL on the lower chain of P whose horizontal span includes x(q) Edge eH or vertex vH on the upper chain of P whose horizontal span includes x(q) We consider four cases If no such edges/vertices exist, we return OUT Else if q is on eL (vL) or on eH (vH), we return ON Else if q is above eL (vL) and below eH (vH), we return IN Else, we return OUT eH P q vL TL

Incremental Convex Hull 1/1/2019 10:28 AM Incremental Convex Hull The incremental convex hull problem consists of performing a series of the following operations on a set S of points locate(q): determines if query point q is inside, outside or on the convex hull of S insert(q): inserts a new point q into S hull(): returns the convex hull of S Incremental convex hull data structure We store the points of the convex hull and discard the other points We store the hull points in two red-black trees TL for the lower hull TH for the upper hull

Convex Hull 1/1/2019 10:28 AM Insertion of a Point In operation insert(q), we consider four cases that depend on the location of point q A IN or ON: no change B OUT and above: add q to the upper hull C OUT and below: add q to the lower hull D OUT and left or right: add q to the lower and upper hull A C D

Insertion of a Point (cont.) Convex Hull 1/1/2019 10:28 AM Insertion of a Point (cont.) q Algorithm to add a vertex q to the upper hull chain in Case B (boundary conditions omitted for simplicity) We find the edge e (vertex v) whose horizontal span includes q w  left endpoint (neighbor) of e (v) z  left neighbor of w While orientation(q, w, z) = CW or COLL We remove vertex w w  z u  right endpoint (neighbor) of e (v) t  right neighbor of u While orientation(t, u, q) = CW or COLL We remove vertex u u  t We add vertex q w e u z t q w u z t

Analysis Let n be the current size of the convex hull 1/1/2019 10:28 AM Analysis Let n be the current size of the convex hull Operation locate takes O(log n) time Operation insert takes O((1 + k)log n) time, where k is the number of vertices removed Operation hull takes O(n) time The amortized running time of operation insert is O(log n)

Data Structure for MST Algorithm Convex Hull 1/1/2019 10:28 AM Data Structure for MST Algorithm current_best$ candidate$ next- node b a IS wait ∞ 9 f 3 yes 6 e 4 d 7 8 c 2 no PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

Quickhull Algorithm for ASC Convex Hull 1/1/2019 10:28 AM Quickhull Algorithm for ASC Reference: [Maher, Baker, Akl, “An Associative Implementation of Classical Convex Hull Algorithms” ] Review of Sequential Quickhull Algorithm Suffices to find the upper convex hull of points that are on or above the line Select point h so that the area of triangle weh is maximal. Proceed recursively with the sets of points on or above the lines and . h e w

Previous Illustration Convex Hull 1/1/2019 10:28 AM Previous Illustration w e h

Example for Data Structure Convex Hull 1/1/2019 10:28 AM Example for Data Structure p1, w p7 p2 P3, e p4 p5 P6, h

Data Structure for Preceding Example Convex Hull 1/1/2019 10:28 AM Data Structure for Preceding Example 1 p3 p1 6 2 p7 9 8 p6 ctr 7 11 p5 h 4 p4 12 IS p2 3 job$ hull$ right-pt$ area$ name$ left-point$ x-coord$ y-coord$ point$ w e PE mask

ASC Quickhull Algorithm (Upper Convex Hull) 1/1/2019 10:28 AM ASC Quickhull Algorithm (Upper Convex Hull) ASC-Quickhull( planar-point-set ) Initialize: ctr = 1, area$ = 0, hull$ = 0 Find the PE with the minimal x-coord$ and let w be its point$ Set its hull$ value to 1 Find the PE with the PE with maximal x-coord$ and let e be its point$ Set its hull$ to 1 All PEs set their left-pt to w and right-pt to e. If the point$ for a PE lies above the line Then set its job$ value to 1 Else set its job$ value to 0

ASC Quickhull Algorithm (cont) Convex Hull 1/1/2019 10:28 AM ASC Quickhull Algorithm (cont) Loop while parallel job$ contains a nonzero value The IS makes its active cell those with a maximal job$ value. Each (active) PE computes and stores the area of triangle (left-pt$, right-pt$, point$ ) in area$ Find the PE with the maximal area$ and let h be its point. Set its hull$ value to 1 Each PE whose point$ is above sets its job$ value to ++ctr sets its job$ to ++ctr Each PE with job$ < ctr -2 sets its job$ value to 0

Performance of ASC-Quickhull Convex Hull 1/1/2019 10:28 AM Performance of ASC-Quickhull  4 6 5 1 2 3

Performance of ASC-Quickhull (cont) Convex Hull 1/1/2019 10:28 AM Performance of ASC-Quickhull (cont) Average Case: Assume Roughly 1/3 of the points above each line being processed are eliminated. O(lg n) points are on the convex hull. Shown to be true for randomly generated points Then the average running time is O(lg n) The average cost is O(n lg n) Worst Case: Running time is O(n). Cost is O(n2) Definition of cost is (running time)  (nr. of processors)

MASC Quickhull Algorithm Convex Hull 1/1/2019 10:28 AM MASC Quickhull Algorithm Algorithm: Use IS1 to execute the first loop of ASC-Quickhull When an IS completes computing the loop in ASC-Quickhull, Idle ISs request problems from busy ISs who have inactive jobs on their job$ list. Control of the PEs for an inactive job is transferred to the idle IS. The control of these PEs is returned to original IS after the job is finished.

ASC Quickhull Algorithm (cont) Convex Hull 1/1/2019 10:28 AM ASC Quickhull Algorithm (cont)  1 2

Analysis for MASC Quickhull Convex Hull 1/1/2019 10:28 AM Analysis for MASC Quickhull Average Case: Assumptions: roughly 1/3 of the points above each line being processed are eliminated. O(lg n) Instruction Streams are available. There are O(lg n) convex hull points The average running time is O(lg lg n) Essentially constant time for real world problems. Worst Case O(n)

MASC Quickhull for a Limited Number of ISs Convex Hull 1/1/2019 10:28 AM MASC Quickhull for a Limited Number of ISs A manager IS is used to control the interactions of the ISs and the task workpool. The manager assigns IS1 to execute the first loop of ASC-Quickhull When an IS completes the execution of a loop, If two jobs are created, it gives one to the manager IS to place on the workpool and then executes the remaining IS If only one job is created, it executes this job next. If no new job is created, this IS requests a new job from the manager IS.

Additional Comments on MASC Quickhull Convex Hull 1/1/2019 10:28 AM Additional Comments on MASC Quickhull For one million points this algorithm would require lg n = 20. Note that increasing the ISs by only 5 (to 25) would allow 33.5 million points to be processed. Even if (lg n) ISs are available for this algorithm, the actual number of ISs would likely to still be less than lg n. It would be inefficient to assume that every time a new task is created, an idle IS would be available to execute it. However, this algorithm should also provide a speedup, even if only a small number k of ISs are available. The complexity of the running time will still be O(lg n). The actual running time could be up to k times faster than for one IS. There will be some loss of efficiency due to IS interactions. This is probably a more practical approach.