Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.

Slides:



Advertisements
Similar presentations
Computational Geometry - Part II Mohammed Nadeem Ahmed Raghavendra Kyatham.
Advertisements

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.
algorithms and data structures
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
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.
Fundamentals of computational geometry M. Ramanathan STTP CAD 2011.
The Divide-and-Conquer Strategy
CS4413 Divide-and-Conquer
The Divide-and-Conquer Strategy
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Divide and Conquer.
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.
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
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.
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.
Algorithms and Data Structures Lecture 13. Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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]
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.
Prune-and-search Strategy
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
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.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
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.
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.
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
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.
© The McGraw-Hill Companies, Inc., Chapter 6 Prune-and-Search Strategy.
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.
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.
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.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
Lecture 3: Parallel Algorithm Design
Introduction to Polygons
Convex Hull R.L. Graham’s Algorithm Computer Graphics.
Convex Hull.
CSCE350 Algorithms and Data Structure
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Convex Sets & Concave Sets
CHAPTER 33 Computational Geometry
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
Computational Geometry Algorithms
Computational Geometry
Convex Hull - most ubiquitous structure in computational geometry
Presentation transcript:

Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections General solution Random lines

Convex Hulls

Convexity A set S is convex if x  S and y  S implies the segment xy  S x y

The segment xy is the set of all points of the form α x + β y with α ≥ 0, β ≥ 0 and α + β = 1 Thus for, End Point x : α = 1 and β = 0, End Point y : α = 0 and β = 1, Mid Point : α = 1/2 and β = 1/2 x(1,0)y(4,0) Segment

A convex combination of points x 1, …, x k is a sum of the form α 1 x 1 + … + α k x k with α i  0 for all i and α 1 + … + α k = 1 Example: 1. Line segment 2. Triangle 3. Tetrahedron Convex Combination

Convex hull of a set of points S is the set of all convex combinations of points of S Convex hull of S is denoted by conv S, sometimes the notation (S) is also used Convex Hull

Some other definitions of Convex Hull Convex Hull of a finite set of points S in the plane is the smallest convex polygon P that encloses S which means that there is no other polygon P ’ such that S  P’  P Intersection of all convex sets containing the points in S

The convex hull of a set of points S in the plane is the union of all the triangles determined by points in S Informal definition: Convex hull of a set of points in plane is the shape taken by a rubber band stretched around the nails pounded into the plane at each point Now we define the convex hull problem: - The problem is to construct the boundary of a convex hull in two dimensions given a finite set S of n points - Four outputs can be distinguished for the above problem: 1. all the points on the hull, in arbitrary order; 2. the extreme points, in arbitrary order; 3. all the points on the hull, in boundary traversal order; 4. the extreme points, in boundary traversal order;

Extreme Points The extreme points of a set S of points in the plane are the vertices of the convex hull at which the interior angle is less than π Also a point is extreme iff there exists a line through that point that other wise does not touch the convex hull

Algorithms to find Extreme Points A] Using Non Extreme Points Identifying non extreme points implies identifying extreme points A point is non extreme iff it is inside some (closed) triangle whose vertices are the points of the set and is not itself a corner of that triangle. Thus given a triangle: If a point is interior to triangle it is non extreme Corners of the triangle might be extreme Thus as the output we will get the extreme points in some arbitrary order.

Algorithm: Interior Points for each i do for each j ≠ i do for each k ≠ i ≠ j do for each l ≠ k ≠ i ≠ j do if p l  Δ(p i,p j, p k ) then p l is nonextreme There are four nested loops in this algorithm Hence the order is O(n 4 ) For each of the n 3 triangles, the test for extremeness costs n It is important to find a faster algorithm

B] Extreme Edges An edge is extreme if every point of S is on or to one side of the line determined by the edge If we treat the edge as directed and let the left side of edge be inside then – the directed edge is not extreme if there is some point that is not left of it or on it The output of this algorithm will be all the points on the convex hull in arbitrary order

Algorithm: Extreme Edges for each i do for each j ≠ i do for each k ≠ i ≠ j do if p k is not left or on (p i,p j ) then (p i,p j ) is not extreme There are three nested loops in this algorithm Hence the order is O(n 3 ) For each of the n 2 pair of points, the test for extremeness costs n The vertices that are extreme can now be found

C] Gift Wrapping (a more realistic hull algorithm) A minor variation of Extreme Edge algorithm can accelerate it by factor n as well as output the points in order The idea is to use one extreme edge as an anchor for finding the next Suppose the algorithm found an extreme edge whose unlinked endpoint is x θ y x e For each y of set S we compute the angle θ The point that yields the smallest θ must determine an extreme edge The output of this algorithm is all the points on the hull in boundary traversal order

Idea: Think of wrapping a gift. Put the paper in contact with the gift and continue to wrap around from one surface to the next until you get all the way around.

Algorithm: Gift Wrapping Find the lowest point (smallest y coordinate) Let i 0 be its index, and set i ← i 0 repeat for each j ≠ i do compute counterclockwise angle θ from previous hull edge Let k be the index of the point with the smallest θ Output (p i,p k ) as a hull edge i ← k until i = i 0 We use the lowest point as the anchor The order is O(n 2 ) The cost is O(n) for each hull edge The point set is wrapped by a string that bends the that bends with minimum angle from previous to next hull edge

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Jarvis March - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Gift Wrapping O(n |H(S)| )

Graham scan O(n log n)

Computer Graphics26 Step 1 Find a point, P, interior to the convex hull (CH) by taking the average of the coordinates of all the given points. Another strategy might be to simply choose yMin. P

Computer Graphics27 Step 2 Translate the interior point, P, and all the others, so the interior point is at the origin. P X Y

Computer Graphics28 Step 3 Find the angle between the line connecting P to each of the points and the positive X-axis. Sort the points according to the magnitude of the angle. The sorting determines the order that the algorithm will process the points. P X Y

Computer Graphics29 Step 4 If two points have the same angle, delete the point with the smaller amplitude (This step creates a new set of points S ’ ). Starting from the lowest Y-Axis coordinate CCW, label the points P0, P1, P2,... P0 P1 P2 P3 P4 P5

Computer Graphics30 Step 5 Let labels Pa, Pb, Pc refer to P0, P1, P2 respectively. P0 P1 P2 P3 P5 Pa Pb Pc P4

Computer Graphics31 Step 6 If the interior angle formed by Pa, Pb, Pc is greater than or equal to 180° then: Eliminate the point labeled with Pb. Set point Pb to point Pa. Set point Pa to the previous point in the sequence (in this case P5). P3 P5 Pa Pb Pc  eliminate P4 Pb Pc P3P4 P5Pa

Computer Graphics32 Step 6 - Cont. If the interior angle formed by Pa, Pb, Pc from before is less than 180° then: No points are eliminated. Each of Pa, Pb and Pc are advanced forward one point. P3 P5 Pa Pb Pc P4  P5 P0 Pb Pc P4 Pa P3

Computer Graphics33 Step 7 The Algorithm continues by repeating step 6 until Pb=P0. At this point, the algorithm stops and only the points of the convex hull remain.

Computer Graphics34 Efficiency Assume n is the number of points in S. Step 1 can be done in O(n) operations. Step 2 can be done in O(n) operations. Step 3 can be done in O(n · Log(n)) operations. Step 4 can be done in O(n) operations. Step 5 can be done in O(1) operations.

Computer Graphics35 Efficiency - Cont. Note that each application of step 6 either eliminates a point (and partially moves backward) or moves forward (advancing Pc). This means that after 2n iterations at the most, we ’ ll end up with the CH. In conclusion, the algorithm will take O(n · Log(n)) operations. This is the Lower Bound complexity. Otherwise we could sort better than O(n · Log(n)).

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p 11 p 12 p 10 p9p9

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Graham Scan - Example p0p0 p1p1 p3p3 p2p2 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 11 p 12 p 10

Convex Hull - Divide and Conquer Algorithm: Find a point with a median x coordinate (time: O(n)) Compute the convex hull of each half (recursive execution) Combine the two convex hulls by finding common tangents. Can be done in O(n) Complexity: O(nlogn)

Convex Hull of Line Intersections. Motivation The database contains roads and the intersections of Tel-Aviv First intersections for an incoming guest are “ important ”. We need to find important intersections, i.e. the convex hull We don ’ t want to check all intersections.

Convex Hull of Line Intersections Applying one of the previous algorithms give O(n 2 log n) time Can we do better?

Algorithm of Atallah 1. Sort the n input lines by decreasing slope. L i = a i x+b i 2. Let q i be the intersection point between L i and L i+1. Q = {q 1, …,q n } 3. Compute CH(Q). It is output of the algorithm

Algorithm of Atallah The algorithm takes O(n log n) time

Correctness LjLj LkLk LiLi v w p

p – corner point => p in Q Suppose that p = L i  L j, i<j If i + 1 = j or i = n-1 and j =0 than p in Q Otherwise there exists k such that a i < a k < a j Since q  p n-1, one of the following is true 1. j  n-1 2. i  0

Correctness (j  n-1) LjLj LkLk LiLi v w L n-1 s p

LjLj LkLk LiLi v w s p

Random Lines Each line is defined by the point with polar coordinates The angles are distributed uniformly in [0, 2π] The distances have common arbitrary distribution R with final E(R)

Random Lines The angles are distributed uniformly in [0, 2π] The distances have common arbitrary distribution R with final E(R)

Random Lines. Results Devroye and Toussaint proved that for this case the expected number of points in the convex hull is O(1)

Random Lines Algorithm Find the points in the convex hull using Atallah algorithm Gift wrapping

Random Lines The sorting in the algorithm of Atallah requires expected linear time Gift wrapping works in expected linear time