Convex Sets & Concave Sets

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

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.
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.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
The Divide-and-Conquer Strategy
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.
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
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.
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]
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.
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
The Art Gallery Problem
Brute-Force Triangulation
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.
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
Triangulating a monotone polygon
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.
1 Computational Geometry Instructor: yedeshi
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.
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.
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.
CLASSIFYING POLYGONS UNIT 1 LESSON 6. Classifying Polygons In geometry, a figure that lies in a plane is called a plane figure. A polygon is a closed.
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.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Convex Hulls Guo Qi, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva.
CMPS 3130/6130 Computational Geometry Spring 2017
Introduction to Spatial Computing CSE 555
Introduction to Polygons
Fill Area Algorithms Jan
Convex Hull.
The Art Gallery Problem
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
The Art Gallery Problem
Polygon Triangulation
Geometry.
Computational Geometry for the Tablet PC
I. The Problem of Molding
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Computational Geometry
CMPS 3120: Computational Geometry Spring 2013
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Computational Geometry Algorithms
Geometry.
Computational Geometry
Presentation transcript:

Convex Sets & Concave Sets A planar region 𝑅 is called convex if and only if for any pair of points 𝑝, 𝑞 in 𝑅, the line segment 𝑝𝑞 lies completely in 𝑅. Otherwise, it is called concave. 𝑝 𝑞 𝑅 2 Concave Convex 𝑝 𝑞 𝑅 1

An Example 4 1 2 3 Regions 1 & 2: convex Regions 3 & 4: concave

Convex Hull The convex hull CH(𝑄) of a set 𝑄 is the smallest convex region that contains 𝑄. Rubber band When 𝑄 is finite, its convex hull is the unique convex polygon whose vertices are from 𝑄 and that contains all points of 𝑄.

Degenerate Cases ♦ The convex hull of a single point is itself. ♦ The convex hull of several collinear points is the line segment joining the two extreme points.

The Convex Hull Problem Input: a set 𝑃 = { 𝑝 1 , 𝑝 2 , …, 𝑝 𝑛 } of points Output: a list of vertices of CH(𝑃) in counterclockwise order. (direction of traversal about the outward axis with the interior on the left) Example 𝑝 1 𝑝 6 𝑝 10 𝑝 7 𝑝 8 𝑝 2 𝑝 5 𝑝 9 𝑝 4 𝑝 3 Output: 𝑝 5 , 𝑝 9 , 𝑝 2 , 𝑝 8 , 𝑝 10 , 𝑝 7 .

Edges of a Convex Hull For every edge with endpoints 𝑝, 𝑞 ∈ 𝑃. All other points in 𝑃 lie to the same side of the line passing through 𝑝 and 𝑞 q p

A Slow Convex Hull Algorithm 𝐸 ≠ {} // set of directed edges of CH(𝑃) that bounds the // points of P on the right. for every ordered pair (𝑝, 𝑞), where 𝑝, 𝑞 ∈ 𝑃 and 𝑝 ≠ 𝑞 // ( 𝑛 2 ) pairs do valid  true for every point 𝑟 ≠ 𝑝 or 𝑞 // 𝑛 −2 such points do if 𝑟 lies to the right of 𝑝𝑞 or collinear with 𝑝 and 𝑞 but not on 𝑝𝑞 then valid  false if valid then 𝐸 ≠ 𝐸 ∪ { 𝑝𝑞 } // 𝑝𝑞 and 𝑞𝑝 cannot be both in 𝐸 From 𝐸 construct a list 𝐿 of vertices of CH(𝑃), sorted in counterclockwise order. // 𝑂( 𝑛 2 ) improvable to 𝑂(𝑛 log 𝑛 ) return L 𝑝 𝑞 𝑟 Running time ( 𝒏 𝟑 )

Polar Angle 𝑦 𝑞 polar angle p 𝑥 𝑟

Graham Scan 1) Select the node with the smallest 𝑦 coordinate. 𝑝 0 This node will be a vertex of the convex hull.

Tie Breaking (1) When more than one point has the smallest 𝑦 coordinate, pick the leftmost (or rightmost) one. 𝑝 0

Sorting by Polar Angle 2) Sort by polar angle with respect to 𝑝 0 . 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 0 Labels are in the polar angle order.

No Polar Angle Evaluation 𝑝 0 is the lowest (and leftmost) all polar angles ∈ 0, 𝜋 . 𝐔𝐬𝐞 𝐜𝐫𝐨𝐬𝐬 𝐩𝐫𝐨𝐝𝐮𝐜𝐭! 𝑝 𝑖 < 𝑝 𝑗 if 𝑝 0 𝑝 𝑖 × 𝑝 0 𝑝 𝑗 >0 𝑝 𝑖 𝑝 𝑗 𝑝 0

Tie Breaking (2) What if 𝑝 0 , 𝑝 𝑖 , 𝑝 𝑗 are on the same line? Order them by distance from 𝑝 0 . 𝑝 𝑖 < 𝑝 𝑗 if and 𝑝 0 𝑝 𝑖 × 𝑝 0 𝑝 𝑗 =0 𝑝 0 𝑝 𝑖 <| 𝑝 0 𝑝 𝑗 | 𝑝 0 𝑝 𝑗 𝑝 𝑖 No square roots. Use dot product! 𝑝 0 𝑝 𝑖 ∙ 𝑝 0 𝑝 𝑖 < 𝑝 0 𝑝 𝑗 ∙ 𝑝 0 𝑝 𝑗

Point Elimination When multiple points have the same polar angle, keep the one furthest from 𝑝 0 . Remove the rest since they cannot possibly be the hull vertices. 𝑝 0 furtherest remove 𝑝 𝑗 𝑝 𝑖

Stack Initialization 3) Scan points in the increasing order of polar angle, maintaining a stack. 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 0 𝑝 2 𝑝 1 𝑆

𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑆 𝑝 3 𝑝 1 𝑝 0

𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑆 𝑝 4 𝑝 1 𝑝 0

𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑆 𝑝 5 𝑝 4 𝑝 1 𝑝 0

𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑆 𝑝 6 𝑝 4 𝑝 1 𝑝 0

𝑆 𝑝 8 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 7 𝑝 6 𝑝 4 𝑝 1 𝑝 0

𝑆 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 7 𝑝 6 𝑝 4 𝑝 1 𝑝 0

𝑆 𝑝 10 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 9 𝑝 6 𝑝 4 𝑝 1 𝑝 0

𝑆 𝑝 11 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 9 𝑝 6 𝑝 4 𝑝 1 𝑝 0

Finish S 𝑝 11 𝑝 6 𝑝 9 𝑝 4 𝑝 9 𝑝 11 𝑝 7 𝑝 6 𝑝 3 𝑝 8 𝑝 4 𝑝 5 𝑝 10 𝑝 1 𝑝 0 𝑝 8 𝑝 10 𝑝 9 𝑝 7 𝑝 6 𝑝 4 𝑝 3 𝑝 1 𝑝 2 𝑝 11 𝑝 5 𝑝 9 𝑝 6 𝑝 4 𝑝 1 𝑝 0

Graham’s Scan 𝑝 𝑗 𝑝 𝑖 𝑝 0 𝑝 𝑘 𝑝 𝑠 𝑝 0 finish 𝑝 𝑗 𝑝 𝑖 𝑝 0 𝑝 0 𝑝 𝑖 𝑝 𝑙  Non-vertices of CH(𝑃) determined so far are popped candidates for vertices of CH(𝑃) 𝑝 𝑠 𝑝 0  finish 𝑝 𝑗 𝑝 𝑖 𝑝 0  𝑝 0 𝑝 𝑖 𝑝 𝑙  𝑝 0 𝑝 2 𝑝 1 start Every point in 𝑃 is pushed onto 𝑆 once vertices of CH(𝑃) in the counter- clockwise order.

The Graham Scan Algorithm let 𝑝 0 be the point in 𝑃 with minimum 𝑦-coordinate let  𝑝 1 , 𝑝 2 , …, 𝑝 𝑛−1  be the remaining points in 𝑃 sorted in counterclockwise order by polar angle around 𝑝 0 . Top[𝑆]  0 Push( 𝑝 0 , 𝑆) Push( 𝑝 1 , 𝑆) Push( 𝑝 2 , 𝑆) for 𝑖 = 3 to 𝑛 − 1 do while 𝑝 𝑖 makes a nonleft turn from the line segment determined by Top(𝑆) and Next-to-Top(𝑆) do Pop(𝑆) Push(𝑆, 𝑝 𝑖 ) return 𝑆

Running time #operations time / operation total Finding 1 (𝑛) (𝑛) 𝑝 0 1 (𝑛) (𝑛) Sorting 1 𝑂(𝑛 log 𝑛 ) O(𝑛 log 𝑛 ) Push 𝑛 𝑂(1) (𝑛) Pop  𝑛 − 2 𝑂(1) 𝑂(𝑛) Why? The running time of Graham’s Scan is 𝑶(𝒏 log 𝒏 ).

Proof of Correctness Claim 1 Each point popped from stack S is not a vertex of CH(P). Proof Two cases when p is popped: j p i j k p i j k In neither case can p become a vertex of CH(P). j

Claim 2 Graham-Scan maintains the invariant that the points on stack S always form the vertices of a convex polygon in counterclockwise order. Proof The claim holds right after initialization of S when p , p , p form a triangle (which is obviously convex). 0 1 2 Popping a point from S preserves the invariant. Consider a point p being pushed onto S. i p j i The region containing p i The invariant still holds.

Correctness of Graham’s Scan Theorem If Graham-Scan is run on a set P of at least three points, then a point of P is on the stack S at termination if and only if it is a vertex of CH(P).

Floating Arithmetic is not Exact! Nearly colinear points p, q, r. q r p p to the left of qr. q to the left of rp. All three accepted as edges! r to the left of qp. Not robust – the algorithm could fail with small numerical error.

Jarvis’ March A “package wrapping” technique p p p p Right chain Left 3 (smallest polar angle w.r.t. p ) 2 p 4 p 2 (smallest polar angle w.r.t. p ) 1 p 5 (smallest polar angle w.r.t. p ) 4 Right chain Left chain p 1 (smallest polar angle w.r.t. p ) p 6 (smallest polar angle w.r.t. p ) 5 p (lowest point)

Running Time of Jarvis’s March Let ℎ be the number of vertices of the convex hull. For each vertex, finding the point with the minimum Polar angle, that is, the next vertex, takes time 𝑂(𝑛). Comparison between two polar angles can be done using cross product. Thus 𝑶(𝒏𝒉) time in total.