Algorithms and Data Structures Lecture 13. Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull.

Slides:



Advertisements
Similar presentations
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Advertisements

Lecture 3: Parallel Algorithm Design
Jarvis March Graham Scan Chan’s Algorithm
algorithms and data structures
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
CS16: Introduction to Data Structures & Algorithms
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
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
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.
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
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]
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
9-1 Chapter 9 Approximation Algorithms. 9-2 Approximation algorithm Up to now, the best algorithm for solving an NP-complete problem requires exponential.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Computational Geometry
Geometric Algorithms1 segment intersection orientation point inclusion simple closed path.
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.
Polygon Scan Conversion and Z-Buffering
Triangulating a monotone polygon
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
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.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
Line Arrangement Chapter 6. Line Arrangement Problem: Given a set L of n lines in the plane, compute their arrangement which is a planar subdivision.
Multitouch and Collision Detection MOBILE SOFTWARE DEVELOPMENT.
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
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.
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.
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
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.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computational Geometry
Computer Graphics Filling.
Computer Graphics CC416 Week 13 Clipping.
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Convex Hull R.L. Graham’s Algorithm Computer Graphics.
Fill Area Algorithms Jan
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Geometry.
Agenda Polygon Terminology Types of polygons Inside Test
Convex Sets & Concave Sets
Agenda Polygon Terminology Types of polygons Inside Test
I. The Problem of Molding
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Convex Hulls Given a set of points (x1,y1),(x2,y2),…,(xn,yn), the convex hull is the smallest convex polygon containing all the points.
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
Computational Geometry Algorithms
Geometry.
Computational Geometry
The two number lines are called the axes.
Presentation transcript:

Algorithms and Data Structures Lecture 13

Agenda: Plane Geometry: algorithms on polygons - Verification if point belongs to a polygon - Convex hull

Verification if point belongs to a polygon Problem: given a polygon P defined by a set of vertices [1…m], given an arbitrary point p; does p belong to a polygon P? Problem can be easily solved for simple polygons like squares and rectangles We need some more general solution that will work for any kinds of polygons

Verification if point belongs to a polygon

The ideas behind the algorithm are the following: - Take arbitrary point x which is out of the considered polygon - Point x should be located far from the polygon - Points p and x are connected by a validation line section - Considering intersections of a validation section with verges of a polygon we can determine whether point p belongs to a polygon or does not

Verification if point belongs to a polygon

If number of intersections is even number or zero – point p lays out of the polygon If number of intersections is odd number – point p belongs to the polygon

Verification if point belongs to a polygon What happens if a validation line intersects verge in start or end point? In this case we do not know whether validation line is transversal or tangent Therefore we do not know if such points should be counted as intersections or should not

Verification if point belongs to a polygon

If validation line contains end-point of some verge (p i-1, p i ) it contains starting-point of verge (p i, p i+1 ) as well Let’s consider both the cases (where validation line is either a transversal or tangent) separately 1.Validation line is a transversal and intersects verges (p i-1, p i ) and (p i, p i+1 ) in point p i

Verification if point belongs to a polygon

2.Validation line is a tangent and touches verges (p i-1, p i ) and (p i, p i+1 ) in point p i

Verification if point belongs to a polygon If rotation directions of verges (p i-1, p i ) and (p i, p i+1 ) are the same – validation line is a tangent and such intersection must not be taken into account If rotation directions of verges (p i-1, p i ) and (p i, p i+1 ) are distinct – validation line is a transversal and such intersection must be taken into account

Plane geometry: Convex hull Let Q is a finite set of points on a plane Convex hull of Q is a minimal convex polygon that contains all the points of Q Convex hull of a set Q is denoted as CH(Q) Some points of a Q are inside the CH(Q), some belong to verges of CH(Q) and some are vertices of CH(Q) None of Q points can be located outside the CH(Q)

Plane geometry: Convex hull

Building a convex hull from a given set of points is a very popular task of plane geometry There are a number of algorithms that solve the problem; they have distinct estimates of running times E.g. so called power method is Θ(n 3 ), where n is a number of points in Q; method’s ideas are the following: (a) for any two points p i p k build a line containing section (p i,p k ); (b) if all the remained points of Q belong either to the left or to the right plane – section (p i,p k ) is a verge of convex hull CH(Q), otherwise section (p i,p k ) is not a verge of a CH(Q); (c) perform verification for all possible pairs of points We will consider two more efficient methods: Graham scan and Jarvis pass

Plane geometry: Graham scan Auxiliary structures: Q – set of points, S – stack of points INPUT: arbitrary set Q, |Q|=n, n>=3 OUTPUT: S – contains vertices of a convex hull There are two additional operations under the stack are defined: - top(S) – returns point from the top of the stack, but stack is not modified (point is not removed) - next_to_top(S) – returns point that is next to the topmost point of the stack; stack is not modified (point is not removed)

Plane geometry: Graham scan Algorithm: 1. Find point p 0 that has minimal y coordinate; if a number of such points available – choose one with minimal x coordinate 2. For each point p 1 …p m-1 calculate its angle relatively to the point p 0 3. Sort points p 1 …p m-1 in ascending order of their angles; if there several points with the same angle – most far point is preserved in Q (relatively to p 0 ), others are removed 4. Points p 0, p 1 & p 2 are added to the S 5. For each point p 3 …p m-1 do … 6. if curve (next_to_top->top->p i ) turns in point “top” leftwards - add p i to the S, otherwise continue removing topmost points from the S until curve changes its direction 7. if there are any points in Q continue for next point ( return to the step 5)

Plane geometry: Graham scan

Plane geometry: Jarvis pass Algorithm: 1. Find point p 0 that has minimal y coordinate; if a number of such points available – choose one with minimal x coordinate 2. Start from point p 0 (point is “current”) 3. For current point do … 4. Calculate angles of all points relatively to the “current” point 5. Choose point with smallest angle; if a number of points have the same angle – we choose most far from “current” point 6. Add new verge 7. Mark just found new point as “current” 8. Continue from step (3) until “current” point returns to point p 0

Plane geometry: Jarvis pass

Plane geometry: Graham scan

Plane geometry: Convex hull Graham scan is O(n*log(n)) Jarvis pass is O(n*h), n= |Q|, h – is a number of vertices in CH(Q)

Q & A