Polygon Triangulation

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

Two Segments Intersect?
UNC Chapel Hill Lin/Foskey/Manocha Steps in DP: Step 1 Think what decision is the “last piece in the puzzle” –Where to place the outermost parentheses.
Incremental Linear Programming Linear programming involves finding a solution to the constraints, one that maximizes the given linear function of variables.
Computational Geometry
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
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
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation (Naive)
POLYGON TRIANGULATION POLYGON TRIANGULATION THE ART GALERY PROBLEM SİNEM GETİR COMPUTER GRAPHIC SEMINAR FEBRUARY 4, 2009.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
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.
1 Voronoi Diagrams. 2 Voronoi Diagram Input: A set of points locations (sites) in the plane.Input: A set of points locations (sites) in the plane. Output:
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.
Overlay of Two Subdivisions
Feb Polygon Triangulation Shmuel Wimer Bar Ilan Univ., School of Engineering.
Zoo-Keeper’s Problem An O(nlogn) algorithm for the zoo-keeper’s problem Sergei Bespamyatnikh Computational Geometry 24 (2003), pp th CGC Workshop.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
Voronoi Diagram Presenter: GI1 11號 蔡逸凡
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 Lecture 2 Polygon Partitioning Thursday,
K-structure, Separating Chain, Gap Tree, and Layered DAG Presented by Dave Tahmoush.
17. Computational Geometry Chapter 7 Voronoi Diagrams.
6/2/ :35 AMIncremental Convex Hull1 q w u e zt.
Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 1 Polygon Triangulation Motivation: Guarding art galleries Art gallery theorem.
Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Polygon Triangulation Motivation: Guarding art galleries Art gallery theorem.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Lecture 2 Chapter 2: Polygon Partitioning.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Polygon Triangulation Computational Geometry, WS 2007/08 Lecture 9 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Voronoi Diagrams.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 2 Chapter 2: Polygon Partitioning.
Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
The Art Gallery Problem
Brute-Force Triangulation
The Art Gallery Problem
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
Triangulating a monotone polygon
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
1 Triangulation Supplemental From O’Rourke (Chs. 1&2) Fall 2005.
2/19/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Voronoi Diagrams Carola Wenk Based on: Computational Geometry:
CMPS 3130/6130 Computational Geometry Spring 2015
1/29/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries Carola Wenk.
UNC Chapel Hill M. C. Lin Computing Voronoi Diagram For each site p i, compute the common inter- section of the half-planes h(p i, p j ) for i  j, using.
Contest Algorithms January 2016 Triangulation & the Art Gallery Problem Contest Algorithms1.
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.
February 17, 2005Lecture 6: Point Location Point Location (most slides by Sergi Elizalde and David Pritchard)
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Polygon Triangulation
Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
3. Polygon Triangulation
A Divide-and-Conquer Algorithm for Delaunay Triangulation CS Gates 219 October 17, 3:00 – 4:20 Richard Zhang (for Leo G.) Disclaimer: All figures.
Introduction to Spatial Computing CSE 555
CMPS 3130/6130 Computational Geometry Spring 2017
Query Processing in Databases Dr. M. Gavrilova
The Art Gallery Problem
Computational Geometry Capter:1-2.1
The Art Gallery Problem
Polygon Triangulation
Depth Estimation via Sampling
I. The Problem of Molding
Overlay of Two Subdivisions
Presentation transcript:

Polygon Triangulation

Triangulation We already know that any polygon can be triangulated by means of diagonals (Theorem 3.1) It is easy to triangulate a convex polygon Therefore the first idea is to decompose a polygon by means of diagonals into convex pieces and then triangulate each piece Unfortunately, to decompose a polygon into convex pieces is as hard as to triangulate it!

Strategy Partition a polygon into monotone pieces Triangulate each monotone piece

Partitioning into monotone pieces

Idea We will use plane sweep method to partition pieces into y-monotone pieces, i.e. the pieces which are monotone with respect to the y-axis

Sweeping a polygon Move line downward and note how the form of the intersection of the line with the polygon changes

Sweeping a polygon Types of vertices: start end regular split merge

Formal definitions With respect to the y-axis, a vertex v is called start v. if its two neighbors lie below it and the interior angle at v is < 180o end v. if its two neighbors lie above it and the interior angle at v is < 180o split v. if its two neighbors lie below it and the interior angle at v is > 180o merge v. if its two neighbors lie above it and the interior angle at v is > 180o other vertices are called regular v v v v

Note In the previous definition, a point q is below another point p if py>qy or py=qy and px < qx For example, the following is a split vertex: v

Lemma 3.4 A polygon without horizontal edges is y-monotone (i.e. monotone with respect to the y-axis) if an only if it has no split or merge vertices y

Proof l y-monotone implies no merge or split vertices Proof by contradiction: assume that P has a split vertex v (similarly for the case of a merge vertex) Let l be a horizontal line below v such that the distance between v and l is less then the distance between l and any other vertex of P Then the intersection of l and P is not connected v l

Proof No merge or split vertices implies monotone Proof by contradiction: assume that P is not monotone Let l be a horizontal line such that the intersection of l and P is not connected Then there exists two points, a and b, in the intersection of l and P, such that the open interval (ab) is in the complement of P Then there exists a chain avi vi+1…vkb, where vi vi+1…vk are consecutive vertices of P, such that this chain does not intersect (ab), and such that the interior of the polygon avi vi+1…vkba lies completely outside of P Suppose that vi vi+1…vk there are vertices above the line l (the case when there are vertices only below is similar) Let v be the highest of such vertices It is easy to see that v is a split vertex

Proof No merge or split vertices implies monotone v l a b

Monotone pieces Thus to partition a polygon into monotone pieces we need to "get rid" of all split and merge vertices We will do this by adding diagonals during the plane sweep: A diagonal going "upward" from each split vertex A diagonal going "downward" from each merge vertex

Plane sweep: preparation Event points are vertices of polygon P Vertices are ordered as follows: p>q if py>qy or py=qy and px < qx It takes O(n log n) time to order vertices No new event points are generated during the plane sweep! Let v1,v2,…,vn be vertices of P in counterclockwise order Let e1,e2,…,en be edges of P such that ei = vivi+1 Each time when the sweep line reaches split vertex we add a diagonal to a vertex lying above the sweep line In the case of merge vertices, diagonals are added later during the algorithm

Helper of an edge For a given position of the sweep line, the helper of an edge e, helper (e), is defined as the lowest vertex above the sweep line such that the horizontal segment connecting the vertex to e lies inside polygon P helper(e) e diagonal

Helper of an edge Note: a helper of an edge can be the upper endpoint of this edge! helper(e') e'

Handling a split vertex Suppose that the sweep line reached a split vertex v We need to connect it to some other vertex so that the diagonal is inside P Therefore a good candidate for this other vertex is a vertex which is close to v in some sense, e.g. in vertical direction If e is the edge immediately to the left of v on the sweep line, we can connect v to the helper(e) Note: v becomes the new helper of e

Handling a split vertex e is immediately to the left of v on the sweep line helper(e) e v New helper(e)

? Example 1 11 9 2 12 7 10 We met a merge vertex It is logical to connect it to vertex 6, which is below! 6 4 8 5 3

Handling a merge vertex Suppose that the sweep line reached a merge vertex v We need to connect it to some other vertex so that the diagonal is inside P We will find this vertex below the sweep line Namely, If e is the edge immediately to the left of v on the sweep line, then v becomes helper(e) We will connect v to the new helper(e) at the moment when it changes! If the helper of e is never replaced, we connect v to the lower endpoint of e

Example e v a a becomes new helper of e, so we connect a and v! v becomes helper of e v e a a becomes new helper of e, so we connect a and v!

Example v becomes helper of e v e a The helper of e never changed until we reached the lower endpoint of e, so we connect the lower endpoint of e and v

Data structures Event (priority) queue Q (contains vertices of P in the order of decreasing y-coordinates) Self-balancing binary search tree T The edges of P intersecting the sweep line are stored in T With each edge in T we store its helper Note: due to the nature of the algorithm, we need to store in T only those edges of P that have the interior of P to their right T, together with helpers, form the status of the algorithm The status changes as the sweep line moves (we update information about edges and helpers) DCEL to store information about P and subsequently added diagonals

Algorithm MakeMonotone(P) Input. A simple polygon P stored in a doubly-connected edge list D Output. A partitioning of P into monotone subpolygons, stored in D Construct a priority queue Q on the vertices of P use y-coordinates to determine priority if two points have the same y-coordinate, the one with smaller x-coordinate has higher priority Initialize an empty binary search tree T While Q is not empty Do remove the vertex vi with the highest priority from Q call the appropriate procedure to handle the vertex, depending on the type of the vertex End Do

HandleStartVertex(vi) HandleEndVertex(vi) Insert ei in T helper(ei)=vi If helper(ei-1) is a merge vertex Insert the diagonal connecting vi to helper(ei-1) in D Delete ei-1 from T vi helper(ei-1) ei vi-1 ei-1 vi+1 vi

HandleSplitVertex(vi) search in T to find the edge ej directly left of vi insert the diagonal, connecting vi to helper(ej), in D helper(ej) = vi insert ei in T helper(ei) = vi helper(ej) ej vi ei New helper(ej) and helper(ei)

HandleMergeVertex(vi) If helper(ei−1) is a merge vertex insert the diagonal connecting vi to helper(ei−1) in D delete ei−1 from T search in T to find the edge ej directly left of vi If helper(ej) is a merge vertex Insert the diagonal connecting vi to helper(ej) in D helper(ej) = vi ei-1 h(ei-1) ej h(ej) vi New helper(ej)

HandleRegularVertex(vi) If the interior of P lies to the right of vi Then If helper(ei−1) is a merge vertex Then Insert the diagonal connecting vi to helper(ei−1) in D End If Delete ei−1 from T Insert ei in T helper(ei) = vi helper(ei−1) ei-1 vi ei

ei ej vi ei-1 Else (i.e. interior of P lies to the left of vi) Search in T to find the edge ej directly left of vi If helper(ej) is a merge vertex Then Insert the diagonal connecting vi to helper(ej) in D End If helper(ej) = vi helper(ej) ei ej vi ei-1 Note: in this case we do not modify T since there is no interior of P immediately to the right of ei or ei-1

Running time Claim. The algorithm MakeMonotone(P), that partitions P into monotone pieces, requires O(n log n) time Notes The algorithm described above is due to Lee and Preparata (1977) It was an open problem whether a faster than O(n log n) time algorithm exists for triangulation of a simple polygon In 1990 Chazelle found an O(n)-time algorithm

Algorithm MakeMonotone(P) Construct a priority queue Q on the vertices of P use y-coordinates to determine priority if two points have the same y-coordinate, the one with smaller x-coordinate has higher priority Initialize an empty binary search tree T While Q is not empty Do remove the vertex vi with the highest priority from Q call the appropriate procedure to handle the vertex, depending on the type of the vertex End Do O (n log n) n times O(n log n) O(log n)

HandleStartVertex(vi) HandleEndVertex(vi) Insert ei in T helper(ei)=vi O(log n) If helper(ei-1) is a merge vertex Insert the diagonal connecting vi to helper(ei-1) in D Delete ei-1 from T O(1) vi O(log n) helper(ei-1) ei vi-1 ei-1 vi+1 vi

HandleSplitVertex(vi) search in T to find the edge ej directly left of vi insert the diagonal, connecting vi to helper(ej), in D helper(ej) = vi insert ei in T helper(ei) = vi O(log n) O(1) helper(ej) ej vi ei New helper(ej) and helper(ei)

HandleMergeVertex(vi) If helper(ei−1) is a merge vertex insert the diagonal connecting vi to helper(ei−1) in D delete ei−1 from T search in T to find the edge ej directly left of vi If helper(ej) is a merge vertex Insert the diagonal connecting vi to helper(ej) in D helper(ej) = vi O(1) O(log n) O(log n) ei-1 O(1) h(ei-1) ej h(ej) vi New helper(ej)

HandleRegularVertex(vi) If the interior of P lies to the right of vi Then If helper(ei−1) is a merge vertex Then Insert the diagonal connecting vi to helper(ei−1) in D End If Delete ei−1 from T Insert ei in T helper(ei) = vi O(1) helper(ei−1) O(log n) ei-1 O(log n) vi ei

ei ej vi ei-1 Else (i.e. interior of P lies to the left of vi) Search in T to find the edge ej directly left of vi If helper(ej) is a merge vertex Then Insert the diagonal connecting vi to helper(ej) in D End If helper(ej) = vi O(log n) O(1) helper(ej) ei ej vi ei-1 Note: in this case we do not modify T since there is no interior of P immediately to the right of ei or ei-1