15-211 Fundamental Data Structures and Algorithms Margaret Reid-Miller 27 April 2004 Computational Geometry.

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Comments We consider in this topic a large class of related problems that deal with proximity of points in the plane. We will: 1.Define some proximity.
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.
Lecture 3: Parallel Algorithm Design
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
Brute-Force Triangulation
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.
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.
1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
Computational Geometry for the Tablet PC
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.
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]
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,
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
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.
Fundamental Data Structures and Algorithms Aleks Nanevski April 22, 2004 Computational Geometry.
Fundamental Data Structures and Algorithms Margaret Reid-Miller 26 April 2005 Computational Geometry.
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.
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.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
Fundamental Data Structures and Algorithms Klaus Sutner April 27, 2004 Computational Geometry.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
Fundamental Data Structures and Algorithms Klaus Sutner April 22, 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.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 9 Line Arrangements.
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.
Polygon Triangulation
Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Convex Sets & Concave Sets
Computational Geometry for the Tablet PC
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Computational Geometry
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Introduction to Algorithms
Computational Geometry Algorithms
Algorithms and Data Structures Lecture XIV
Convex Hull - most ubiquitous structure in computational geometry
Complexity Theory: Foundations
Presentation transcript:

Fundamental Data Structures and Algorithms Margaret Reid-Miller 27 April 2004 Computational Geometry

Announcements  HW7 the clock is ticking...  Final Exam on Tuesday May 4, 5:30 pm  review session Thursday, April 29

Recall: Convex Hull

A Hull Operation Suppose P is a set of points in the plane. The convex hull of P is the least set of points Q such that: - P is a subset of Q, - Q is convex. Written CH(P). This pattern should look very familiar by now (reachability in graphs, equivalence relations,...)

Convex Combinations Abstractly it is easy to describe CH(P): is the set of all points X =  i P i where 0  i and  i = 1. X is a convex combination of the P i. So the convex combinations of A and B are the line segment [A,B]. And the convex combinations of three points (in general position) form a triangle. And so on.

So? Geometrically this is nice, but computationally this characterization of the convex hull is not too useful. We want an algorithm that takes as input a simple polygon P and returns as output the simple polygon CH(P). P CH(P)

An Algorithm Hence we can find the convex hull of a simple polygon: for all n points we eliminate non-extremal points by trying all possible triangles using the membership test for convex polygons. In the end we sort the remaining extremal points in counterclockwise order. Unfortunately, this is O(n 4 ). Could it be faster? When do we get n 4 ?

CH Algorithms Let us assume that the input is given as a set (list) P of n points p 1,p 2,...,p n in the plane. Example, 1.223, , , , , , , , We need to compute the extremal points and ouput them in some natural order (say, traversing the boundary of the hull counterclockwise, starting at the south-east corner). However, the input may not be ordered in any particular way.

Application: Membership Test The output convention makes algorithmic sense: we can then test in logarithmic time whether a point lies in the convex region. Q Q

Membership in Convex Polygon Recall: Traverse the boundary of the convex polygon in counterclockwise order, check that the point in question is always to the left of the corresponding line. This is clearly linear in the number of boundary points.

Membership Test c't Find central point p, then use binary search to identify the sector that Q belongs to: between rays [p,p i ) and [p,p i+1 ). Check if Q lies in the corresponding triangle. p Q Q p i+1 pipi

Computation and Physics Note that there is a simple analogue algorithm to solve the convex hull problem: use a board, nails and a rubber band. Is linear (analog) time.

Extremal Points It is easy to find a few points guaranteed to be on the convex hull. p0p0

Some CH Algorithms

Jarvis' March Suppose we already have an extremal point p 0 on the boundary of the convex hull. Assume wlog that p 0 is the origin and that all points lie in the upper half plane. Why is this OK? p0p0

Gift Wrapping Then find the other extremal points as follows: tie a string to p 0 and then wrap it all around P. extremal p 0 p 1 p 2 p 3 p 4 p0p0 p1p1 p2p2 p3p3 p4p4

Complexity This can be implemented in O( e n ) steps where e is the number of extremal points. p0p0 p1p1 p2p2 p3p3 p4p4

Graham Scan Here is another idea: Order the points with respect to their polar coordinates. As origin use either an interior point or, say, the lowest extreme point. p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p6p6

Graham-Scan p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 The march around the points in polar order. Keep track of the last two edges. We would like to see a sequence of left turns.

Graham-Scan p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p7p7 If there is a right turn, the previous point was not extremal and has to be discarded (back out).

Graham-Scan Stack p 0 p 1 p 2 p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 Stack p 0 p 1 p 3 p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p7p7

Graham-Scan p6p6 Stack p 0 p 1 p 3 p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p7p7 Stack p 0 p 1 p 3 p 4 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2

Stack p 0 p 1 p 3 p 4 p 5 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2 Graham-Scan Stack p 0 p 1 p 3 p 4 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2

Graham-Scan Stack p 0 p 1 p 3 p 6 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2 Stack p 0 p 1 p 3 p 4 p 5 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2

Graham-Scan Stack p 0 p 1 p 3 p 6 p0p0 p1p1 p3p3 p4p4 p5p5 p6p6 p7p7 p2p2 Stack p 0 p 1 p 3 p 6 p 7 p0p0 p1p1 p3p3 p4p4 p6p6 p7p7 p2p2 p5p5

Graham-Scan Stack p 0 p 1 p 3 p 6 p 7 p0p0 p1p1 p3p3 p4p4 p6p6 p7p7 p2p2 p5p5 Stack p 0 p 1 p 3 p 6 p 7 p0p0 p1p1 p3p3 p4p4 p6p6 p7p7 p2p2 p5p5

Graham-Scan Stack p 0 p 1 p 3 p 6 p 7 p0p0 p1p1 p3p3 p4p4 p6p6 p7p7 p2p2 p5p5

Running Time Graham Graham scan can be implemented in O( n log n ) steps. - O(n) steps to find the anchor point (or O(1)). - O(n log n) steps to sort the points. - O(1) for the local tests. - O(n) steps in the traversal: touch every point at most twice.

Jarvis and Graham Jarvis' March and Graham's Scan are rather similar. Both are somewhat related to sweep-line techniques. Sometimes called “rotational sweep”.

Correctness Graham Best shown using a loop invariant: The CH of the points so far inspected is spanned by the points in the stack. The algorithm does precisely what is necessary to maintain this invariant. p0p0 p1p1 p3p3 p4p4 p5p5 p7p7 p2p2

Exercise Give a correctness proof for Jarvis’ algorithm. p0p0 p1p1 p2p2 p3p3 p4p4

Lower Bound for CH O( n log n ) is optimal for convex hull. Show that Sorting can be reduced to Convex Hull. Consider n positive real numbers x i. Define p i = (x i,x i 2 ). Easy to see: are all extremal. Traversing the boundary of CH(P) produces a sorted list.

Polar Coordinates It is important not to waste time in the coordinate computations. Cartesian (x,y)  polar (r, ) r = Sqrt( x 2 + y 2 )  = arctan( y/x ) arctan expensive and not needed! Instead find quadrant of point, then within each quadrant use slopes for angle comparisons.

Quick Hull Divide-and-Conquer is supposedly a universal algorithm design tool. Does it apply to convex hulls? We need to break the points into two groups, get the hulls of both sets and then construct the total hull from the pieces. To get O(n log n) the overhead must be linear.

Quick Hull Idea Find two points p and q such that [p,q] is a chord in the convex hull of P. Split the points into “above” and “below” the baseline [p,q].

Upper Half Find the point r furthest from the baseline. Discard all points in the triangle (p,q,r).

Repeat In the end only the extremal points are left over.

Comments The divide step is clearly linear (in the number of points on that side). Combining the solutions is trivial here: we can just join the lists of extremal points. This is very similar to Quicksort.

Analysis When does this approach work well? When does it work poorly? What is the running time in general? What is average running time? Can we force fast behavior?

Analysis When does this approach work well? When does it work poorly? O( n 2 ) What is the running time in general? O( n log n) What is average running time? O( n ) Can we force fast behavior?

Applications Fundamental subroutine Minimum Spanning Tree where distance is Eulidean Dual of finding feasible region of linear half spaces Linear programming Delauney triangulation

Recall: Motion Planning Our motion planning problem is slightly related to convex hulls: Given a collection P of obstacles in space-time, we want to compute the c-hull of P: c-hull(P) = { p position | robot at p is doomed } c here is the maximum speed, so -hull(P) = P. Note that this is also a hull operator, just like CH: P subset of c-hull(P) c-hull( c-hull(P) ) = c-hull( P ) Smallest such set with certain closure properties.

c-Hull But the geometry of the c-hull is more complicated than the convex hull. E.g. think about rotations. Still can use a sweep-line algorithm to compute the c- hull in O(n log n) steps.

Obstacle Avoidance Once the c-hull has been computed we can avoid the obstacles by “sliding along” the hull (though there may be better paths).

Exercise Figure out which closure property defines the c-hull. It should be analogous to the condition for CH: p,q in set implies [p,q] in set.