Convex Hull.

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
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.
algorithms and data structures
Brute-Force Triangulation
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
1 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.
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.
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
The Divide-and-Conquer Strategy
Theory of Algorithms: Divide and Conquer
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 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.
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.
Polygons and the convex hull Prof. Noah Snavely CS1114
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]
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.
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.
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.
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
Divide and Conquer.
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.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 5 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
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.
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.
CMPS 3130/6130 Computational Geometry Spring 2017
Introduction to Polygons
Chapter 4 Divide-and-Conquer
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
Convex Hull R.L. Graham’s Algorithm Computer Graphics.
CSCE350 Algorithms and Data Structure
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Geometry.
Convex Sets & Concave Sets
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Divide-and-Conquer The most-well known algorithm design strategy:
CMPS 3120: Computational Geometry Spring 2013
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Introduction to Algorithms
Computational Geometry Algorithms
Geometry.
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Presentation transcript:

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 nails, let go, and the rubber band will form a shape around the outermost nails, encompassing the rest. The shape formed is known as the convex hull. Formerly, the convex hull of a set of points X in a real vector space V is the smallest convex set containing X. An object is convex if for every pair of points within the object, every point on the straight line segment that joins them is also within the object. If a polygon contains angles of 180 degrees or more, it is not convex.

Basic Concepts If the set of points given contains only one point, that point is its own convex hull. The convex hull of two unique points is the line segment between the two points. The convex hull of three nonlinear points is the triangle formed by these three points. If the points are collinear, the convex hull is the line segment connecting the points with the endpoints as extreme points. An extreme point is a point that lies on the convex hull. In other words, one of the vertices on the polygon that the hull forms. Four extreme points are obvious when given a set those to the furthest right and left, and those at the top and bottom. Computational geometry is defined as the study of algorithms to solve problems in computer science in terms of geometry. There are several different algorithms with different efficiencies used to solve the problem of the convex hull.

Jarvis March Also known as the “gift wrapping” technique. Start at some extreme point on the hull. In a counterclockwise fashion, each point within the hull is visited and the point that undergoes the largest right-hand turn from the current extreme point is the next point on the hull. Finds the points on the hull in the order in which they appear. Example: http://www.cs.princeton.edu/courses/archive/spr10/cos226/demo/ah/JarvisMarch.html

Implementation In order to find the biggest right hand turn, the last two points added to the hull, p1 and p2, must be known. Assuming p1 and p2 are known, the angle these two points form with the remaining possible hull points is calculated. The point that maximizes the angle is the next point in the hull. To do this, we have two line segments p0p1 and p1p2. We are trying to determine the value of the right hand turn at p1. To do this we find the cross product of (p1 – p0) x (p2 – p0). The point that gives the largest value in this calculation is the next point on the hull. Continue to make right turns until the original point is reached and the hull is complete.

Efficiency Proposed by R.A. Jarvis in 1973 O(nh) complexity, with n being the total number of points in the set, and h being the number of points that lie in the convex hull. This implies that the time complexity for this algorithm is the number of points in the set multiplied by the number of points in the hull The worst case for this algorithm is denoted by O(n2), which is not optimal. Favorable conditions in which to use the Jarvis march include problems with a very low number of total points, or a low number of points on the convex hull in relation to the total number of points.

Graham’s Scan Sort points by increasing y-coordinate values. In the case of a tie, the leftmost x-coordinate value comes first. This known as the anchor point. In Graham’s scan, the remaining points in the set are then sorted in increasing order of the angle made by the x-axis, the point P, and the point in the remaining set. Therefore, the points furthest right with the smallest angles formed will be the first points in the sort, while the points lying furthest to the left will be the last points. http://www.cs.princeton.edu/courses/archive/fall08/cos226/demo/ah/GrahamScan.html

Graham’s Scan Once the points are sorted in order in respect to the anchor point from rightmost to leftmost, the anchor point and the point lying furthest to the right (the first point in the sorted data) must both be on the hull. These two points serve as our initial points on the hull and are pushed onto a stack representing hull points. From here, for each consecutive point in the sort, it is determined whether a right or left turn is taken from the top two items on the stack to the point. (cross product). As long as a left hand turn is made, push the point onto the stack. When a right hand turn is made, pop top point off the stack, reevaluate and continue popping as long as right hand turns are made. Then push the new point onto the stack. When the initial point is reached again, the points on the stack represent the convex hull.

Pseudocode # Points[1] is the pivot or anchor point Stack.push(Points[1]); Stack.push(Points[2]); FOR I = 3 TO Points.length o = Cross_product(Stack.second, Stack.top, Points[i]; IF o == 0 THEN Stack.pop; Stack.push(Points[i]); ELSE WHILE o <= 0 and Stack.length > 2 o = Cross_product(Stack.second, Stack.top, Points[i]); ENDWHILE NEXT i

Efficiency In the Graham Scan, the first phase of sorting points by angle around the anchor point is of time O( n logn) complexity. Phase 2 of this algorithm has a time complexity of O(n). The total time complexity for this algorithm is O( n logn) which is much more efficient than a worse case scenario of Jarvis march at O(n2).

Divide and Conquer In this method, two separate hulls are created, one for the leftmost half of the points, and one for the rightmost half. To divide in halves, sort by x-coordinates and find the median. If there is an odd number of points, the leftmost half should have the extra point. Recursively find the convex hull for the left set of points and the right set of points. This gives hull A and hull B. Stitch together the two hulls to form the hull of the entire set. http://www.cse.unsw.edu.au/~lambert/java/3d/divideandconquer.html

Implementation To stitch the hulls together, the upper and lower tangent lines must be found. To find the lower tangent, start with the rightmost point in hull B and the leftmost point in hull A. While the line segment formed between these two points is not the lower tangent line of the hull, figure which of the two points is not at its lower tangent point. While A is not the lower tangent point, move around the hull clockwise, that is A=A – 1. While B is not at the lower tangent point, move around the hull counterclockwise, that is B = B + 1. When the upper and lower tangent lines are found, march around hull A and hull B deleting the points that are now within the merged convex hull.

Efficiency The divide and conquer algorithm is also of time complexity O( n logn). This algorithm is often used for cases in three dimensions. A technicality of the divide and conquer method lies in how many points are in the set. If the set has less than four points, there is no need to sort the points, but rather for these special cases, determine the hull separately. A downside to this algorithm is the overhead associated with recursive function calls.

Quickhull Interactive, redraw as you go algorithm. Similar to quicksort in efficiency. Sort in terms of increasing x-coordinate values. Find four extreme points and form a quadrilateral. Discard all points that lie within the quadrilateral. Each edge of the quadrilateral is then examined to see whether any points lie outside the edge of the current hull. A triangle is drawn from the edge to the point that lies the furthest outside of the edge. Any points within this triangle are eliminated because they do not lie on the hull. The original edge is removed and new edges are formed with the new point and two closest extreme points. Edges added to a bucket from which recursion takes place to find any points that lie outside the edge and drawing new triangles until all points are eliminated other than the vertices of the hull. http://www.cs.princeton.edu/courses/archive/spr10/cos226/demo/ah/QuickHull.html

Efficiency Proposed by Preparata and Hong in 1977 Quickhull method exhibits O( n logn) complexity. For unfavorable inputs, the worst case can be O(n2). Overall, this algorithm is dependent upon how evenly the points are split at each stage. At times this algorithm can be more useful than Graham’s scan, but if the points are not evenly distributed then it is often not. Points uniformly distributed in a square can throw out all inner points in only a few iterations. The quickhull algorithm saves time in that the quicksort of the points (splitting then into an upper and lower hull) splits the problem into two smaller sub-problems that are solved the same way. It also saves time due to the fact that a significant amount of points that lie within the quadrilateral formed can be eliminated immediately. The main disadvantage to this algorithm is the overhead associated with recursive function calls.