Computing Convex Hulls CLRS 33.3

Slides:



Advertisements
Similar presentations
Computational Geometry The systematic study of algorithms and data structures for geometric objects, with a focus on exact algorithms that are asymptotically.
Advertisements

Computational Geometry
Computational Geometry
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
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
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.
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
Ruslana Mys Delaunay Triangulation Delaunay Triangulation (DT)  Introduction  Delaunay-Voronoi based method  Algorithms to compute the convex hull 
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.
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.
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.
Computational Geometry for the Tablet PC
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.
ADA: 16. CG Topics1 Objective o an examination of four important CG topics o just a taster of a very large research area Algorithm Design and Analysis.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
6/2/ :35 AMIncremental Convex Hull1 q w u e zt.
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.
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.
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
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
A brief and sketchy intro to 3D Convex Hulls Rodrigo Silveira GEOC 2010/11 - Q2.
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.
RA PRESENTATION Sublinear Geometric Algorithms B 張譽馨 B 汪牧君 B 李元翔.
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.
CMPS 3120: Computational Geometry Spring 2013
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
UNC Chapel Hill M. C. Lin Delaunay Triangulations Reading: Chapter 9 of the Textbook Driving Applications –Height Interpolation –Constrained Triangulation.
Computational Geometry 2D Convex Hulls
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.
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
CS6234 Advanced Algorithms - Convex hull. Terminologies – ◦ Convex hull of a set Q of points is the smallest convex polygon P for which each point in.
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
Introduction to Polygons
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.
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
Computational Geometry Algorithms
Algorithms and Data Structures Lecture XIV
Computational Geometry
Convex Hull - most ubiquitous structure in computational geometry
Presentation transcript:

Computing Convex Hulls CLRS 33.3

Computational Geometry Studies algorithms for solving geometric problems Applications in many fields Computer graphics Robotics VLSI design Computer-aided design, etc.

Geometric algorithms The input (typically): a description of a set of geometric objects A set of points A set of line segments Vertices of a polygon Etc. We will look at sample problems in two dimensions, that is, in the plane

Convex hulls in two dimensions What is a convex hull? What is convexity? A subset S of the plane is called convex if and only if for any pair of points p, q in S, the line segment pq is completely contained in S p q p q not convex convex

Convex Hull The convex hull CH(S) of a set s is the smallest convex set that contains S. Consider the problem of computing the convex hull of a finite set P of n points in the plane.

Convex Hull

Convex Hull

Convex Hull Alternative Definition: It is the unique convex polygon whose vertices are points from P and contains all the points of P

Problem Given P, compute a list of points that contains the vertices of CH(P), listed in clockwise (CW) order Expected output:

Brute-Force Solution Consider an edge of the convex hull between vertices p and q Consider the directed line passing through p and q Observe that CH(P) lies to the right of this line q p

Brute-Force Solution Reverse holds too: If all points in lie to the right of the directed line through p and q, the pq is an edge of CH(P) q p

BruteForce_ConvexHull(P) { E=empty set for all ordered pairs (p,q) in PxP, and p!= q do { isEdge = true for all points r in P, r!=p and r!=q do if r lies to the left of directed line from p to q isEdge= false if isEdge the add pq to E } from the set of edges in E, construct a list L of vertices of CH(P), in CW order return L

How to test? if r lies to the left of directed line from p to q

Orientation test Given an ordered triple of points <p,q,r> in the plane, we say that they have positive orientation if they define a CCW oriented triangle negative orientation if they define a CW oriented triangle Zero orientation if they are collinear p q r Positive orientation p q r r is to the left of pq

Orientation test Given an ordered triple of points <p,q,r> in the plane, we say that they have positive orientation if they define a CCW oriented triangle negative orientation if they define a CW oriented triangle Zero orientation if they are collinear q q r r p p negative orientation r is to the right of pq

Orientation test Given an ordered triple of points <p,q,r> in the plane, we say that they have positive orientation if they define a CCW oriented triangle negative orientation if they define a CW oriented triangle Zero orientation if they are collinear q q r r p p zero orientation r is on pq

Orientation

How about the last step? Given E, construct the list of vertices of CH(P) in CW order?

How about the last step? Given E, construct the list L of vertices of CH(P) in CW order? Remove an arbitrary edge pq from E, put p and q in L Now find in E the edge with origin q (say qr), remove that edge from E and add r to L Keep doing this until E has only one edge left time to contsruct L why?

Overall, BruteForce takes How many ordered pairs? n (n-1) For each we compare n-2 other points (r)

Can we do better? A number of algorithms that can compute CH(P) in O(n log n) We will study the Incremental Algorithm Points are added one at a time and the hull is updated at each insertion

Incremental Algorithm At any intermediate step of the algorithm There is a current hull of points Add point Update the hull Add points in order of increasing x-coordinate To guarantee that the new point is outside the current hull If same x-coordinate, then in increasing order of y

Upper Hull and Lower Hull We will construct the hull in two pieces: construct upper hull from left to right construct lower hull from right to left

Construction of the Upper Hull already processed

Construction of the Upper Hull Observation: for a convex polygon, if we walk through the boundary in CW order, we always make a right turn i.e. if we consider any three consecutive points: p, q, r Orient(p,q,r) should be negative How can we use this?

Construction of the Upper Hull Check whether the last two points on the current hull and make a right turn Left turn

Construction of the Upper Hull If a left turn, remove the last point from the current hull and try again Left turn

Construction of the Upper Hull If a left turn, remove the last point from the current hull and try again Left turn

Construction of the Upper Hull If a left turn, remove the last point from the current hull and try again Left turn

Construction of the Upper Hull If a right turn, add to the current hull right turn

Construction of the Upper Hull If a right turn, add to the current hull right turn

Store current hull on a stack U U.top() returns the last point on the current hull U.second() returns the second to last point on the current hull while ( Orient(U.second(), U.top() ) >= 0) U.push( ) U.pop()

IncrementalConvexHull(P) { sort points in increasing order of their x-coordinate U.push(p[1]) U.push(p[2]) for i=3 to n do while U.size() >= 2 and orient(U.second(), U.top(), p[i]) >= 0) do U.pop() U.push(p[i]) L.push(p[n]) L.push(p[n-1]) for i=n-2 to 1 do while L.size() >= 2 and Orient(L.second(), L.top(), p[i]) >= 0) do L.pop() L.push(p[i]) Combine U and L into a single list of points in CW direction

Incremental Convex Hull Running time? Sort: O(n log n) Each point is removed from the stack U at most once: O(n) Each point is entered into the stack U once: O(n) Thus, O(n) for upper hull Similarly O(n) for lower hull Total: O(n log n)