Brute-Force Triangulation

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Polygon Triangulation
Computational Geometry
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
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.
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
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
Feb Polygon Triangulation Shmuel Wimer Bar Ilan Univ., School of Engineering.
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.
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.
Computational Geometry -- Voronoi Diagram
17. Computational Geometry Chapter 7 Voronoi Diagrams.
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.
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
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
Computational Geometry Piyush Kumar (Lecture 4: Planar Graphs, Polygons and Art Gallery) Welcome to CIS5930.
The Art Gallery Problem
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
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.
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.
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.
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.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 9 Line Arrangements.
Polygon Triangulation
Computational Geometry
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
CMPS 3130/6130 Computational Geometry Spring 2017
3. Polygon Triangulation
Computational Geometry
Introduction to Spatial Computing CSE 555
Introduction to Polygons
Query Processing in Databases Dr. M. Gavrilova
The Art Gallery Problem
Computational Geometry 2
Computational Geometry Capter:1-2.1
The Art Gallery Problem
Polygon Triangulation
Convex Sets & Concave Sets
I. The Problem of Molding
Computational Geometry
Overlay of Two Subdivisions
Presentation transcript:

Brute-Force Triangulation 1. Find a diagonal. 2. Triangulate the two resulting subpolygons recursively. How to find a diagonal? w u v u v w leftmost vertex case 2 closest to v case 1 O(n) time to find a diagonal at every step. (n ) time in the worst case. 2

Triangulating a Convex Polygon (n) time! Idea: monotone Decompose a simple polygon into convex pieces. Triangulate the pieces. as difficult as triangulation

y-monotone Pieces Stragegy: y-axis y-monotone if any line perpendicular to the y-axis has a connected intersection with the polygon. highest vertex Stragegy: walk always downward or horizontal Partition the polygon into monotone pieces and then triangulate. lowest vertex

Turn Vertex Turn vertex is where the walk from highest vertex to the lowest vertex switches direction. At vertex v  Both adjacent edges are below. v The polygon interior lies above. Choose a diagonal that goes up.

Five Types of Vertices Point p = (x, y) is “below” a different point q = (u, v) if p q y < v or y = v and x > u. p q Otherwise p is “above” q. 4 types of turn vertices Start vetex: lies above its two neighbors and has interior angle < . Split vetex: lies above its two neighbors and has interior angle > . End vetex: lies below its two neighbors and has interior angle < . Merge vetex: lies below its two neighbors and has interior angle > . Regular vetex: the remaining vertices (no turn). What happens if we rotate the polygon by ? start vertices  end vertices split vertices  merge vertices

Local Non-Monotonicity Lemma A polygon is y-monotone if it has no split or merge vertices. Proof Suppose the polygon is not y-monotone. We prove that it contains a split or merge vertex. split vertex There exists a horizontal line l intersecting the polygon in >1 components, of which the leftmost is a segment between some vertices p (left) and q (right). interior p q l exterior Start at q, traverse the boundary counterclockwise until it crosses the line l again at point r. r r = p q p = r l exterior interior Traverse in the oppose direction from q and crosses line l again at point r’. The lowest point during this traversal must be a merge vertex. r r  p The highest vertex during the traversal from q to r must be a split vertex. merge vertex

Partitioning into Monotone Pieces The lemma implies that the polygon will have y-monotone pieces once its split and merge vertices are removed.  Add a downward diagonal at every merge vertex.  Add an upward diagonal at every split vertex. Use a downward plane sweep. No new event point will be created except the vertices. The event queue is implemented as priority queue (e.g., heap). The next event found in time O(log n).

Removal of a Split Vertex v : split vertex i e : edge immediately to its left. j e k e : edge immediately to its right. k h(e ) j v i e j j k h(e ): lowest vertex above v and between e and e . i e i-1 e i or the upper vertex of e if such vertex does not exist. j edge helper Connect v to h(e ). i j

Removal of a Merge Vertex Merge vertices can be handled the same way in an upward sweep as split vertices in a downward sweep. But why not all in the same sweep? v : merge vertex i v i e : edge immediately to its left. j e j e : edge immediately to its right. k e k v m v : highest vertex below the sweep line and between e and e . m j k i Connect v to v . m v will replace v as the helper of e . m i j Check if the old helper is a merge vertex and add the diagonal if so. (The diagonal is always added if the new helper is a split vertex). In case the helper of e is not replaced any more, connect to its lower endpoint. j

Sweep-Line Status Implemented as a binary search tree. Only edges to the left of the polygon interior are stored. This is because we are only interested in edges to the left of split and merge vertices. Edges are stored in the left-to-right order. With every edge e its helper h(e) is also stored.

DCEL Representation Construct a doubly-connected edge list to represent the polygon. n vertices + n edges + 2 faces (initially) Add in diagonals computed for split and merge vertices. Edges in the status BST and corresponding ones in DCEL cross-point each other. Adding an edge can be done in O(1) time.

The Algorithm MakeMonotone(P) Input: A simple polygon P stored in DCEL D. Output: A partitioning of P into monotone subpolygons stored in D. 1. Q  priority queue storing vertices of P 2. T   // initialize the status as a binary search tree. 3. i  0 4. while Q   5. do v  the highest priority vertex from Q // removal from Q 6. case v of 7. start vertex: HandleStartVertex(v ) 8. end vertex: HandleEndVertex(v ) 9. split vertex: HandleSplitVertx(v ) 10. merge vertex: HandleMergeVertex(v ) 11. regular vertex: HandleRegularVertex(v ) 12. i  i + 1 i i i i i i i

Handling Start & End Vertices insert into T HandleStartVertex(v ) 1. T  T  { e } 2. h(e )  v // set the helper i v 5 v 3 e 5 v 4 e 4 v 6 e 3 e 6 v 1 v 14 e 2 v 7 v 2 v 9 HandleEndVertex(v ) if h(e ) is a merge vertex then insert the diagonal connecting v to h(e ) in D 3. T  T – { e } i i –1 i -1 v 8 e 7 e 1 e 8 e 15 e 14 e 9 v 12 v 15 v 10 e 10 e 11 e 13 e 12 v 11 v 13

Handling Split Vertex HandleSplitVertex(v ) Search in T to find e directly left of v insert the diagonal connect v to h(e ) into D h(e )  v 4. T  T + { e } 5. h(e )  v i j v 5 v 3 e 5 v 4 e 4 v 6 e 3 e 6 v 1 e 2 v 7 v 2 v 9 v 8 e 7 e 1 e 8 e 15 v 14 e 14 e 9 v 12 v 15 v 10 e 10 e 11 e 13 e 12 v 11 v 13

Handling Merge Vertex (1) HandleMergeVertex(v ) if h(e ) is a merge vertex then insert the diagonal connecting v to h(e ) in D 3. T  T – { e } Search in T to find the edge e directly left of v . 5. if h(e ) is a merge vertex connecting v to h(e ) 6. h(e )  v i i –1 i -1 j v 5 v 3 e 5 v 4 e 4 v 6 e 3 e 6 v 1 e 2 v 7 v 2 v 9 v 8 e 7 e 1 e 8 e 15 v 14 e 14 e 9 v 12 v 15 v 10 e 10 e 11 e 13 e 12 v 11 v 13

Handling Merge Vertex (2) HandleMergeVertex(v ) if h(e ) is a merge vertex then insert the diagonal connecting v to h(e ) in D 3. T  T – { e } Search in T to find the edge e directly left of v . 5. if h(e ) is a merge vertex connecting v to h(e ) 6. h(e )  v i i –1 i -1 j e i – 1 e j h(e ) j h(e ) i –1 v i

Handling Regular Vertices (1) HandleRegularVertex(v ) if the polygon interior lies to the right of v 2. then if h(e ) is a merge vertex 3. then insert the diagonal connecting v to h(e ) in D 4. T  T – { e } 5. T  T + { e } 6. h(e )  v 7. else search in T to find the edge e directly left of v . 8. if h(e ) is a merge vertex then insert the diagonal connecting v to h(e ) 9. h(e )  v i i –1 i -1 j v 5 v 3 e 5 v 4 e 4 v 6 e 3 e 6 v 1 e 2 v 7 v 2 v 9 v 8 e 7 e 1 e 8 e 15 v 14 e 14 e 9 v 12 v 15 v 10 e 10 e 11 e 13 e 12 v 11 v 13

Handling Regular Vertices (2) HandleRegularVertex(v ) if the polygon interior lies to the right of v 2. then if h(e ) is a merge vertex 3. then insert the diagonal connecting v to h(e ) in D 4. T  T – { e } 5. T  T + { e } 6. h(e )  v 7. else search in T to find the edge e directly left of v . 8. if h(e ) is a merge vertex then insert the diagonal connecting v to h(e ) 9. h(e )  v i i –1 i -1 j e j v i h(e ) j

Correctness Theorem The algorithm adds a set of non-intersecting diagonals that partitions the polygon into monotone pieces. Proof The pieces that result from the partitioning contain no split or merge vertices. Hence they are monotone by an earlier lemma. We need only prove that the added segments are diagonals that intersect neither the polygon edges nor each other. Establish the above claim for the handling of each of the five type of vertices during the sweep. (Read the textbook on how to do this for the case of a split vertex.)

Running Time on Partitioning MakeMonotone(P) Input: A simple polygon P stored in DCEL D. Output: A partitioning of P into monotone subpolygons stored in D. 1. Q  priority queue storing vertices of P 2. T   3. i  0 4. while Q   5. do v  the highest priority vertex from Q 6. case v of 7. start vertex: HandleStartVertex(v ) 8. end vertex: HandleEndVertex(v ) 9. split vertex: HandleSplitVertx(v ) 10. merge vertex: HandleMergeVertex(v ) 11. regular vertex: HanleRegularVertex(v ) 12. i  i + 1 // O(n) heap construction // O(log n) i i // O(log n) each case i // queries and updates // in O(log n) time and // insertion of a diagonal // in O(1) time. i i i i Total time: O(n log n) Total storage: O(n)

Triangulating a y-Monotone Polygon Assumption The polygon is strictly y-monotone (no horizontal edges). It is for clarity of presentation and will be easily removed later. Order of processing: in decreasing y-coordinate. A stack S: vertices that have been encountered and may still need diagonals. convex vertex lowest vertex on top. funnel Idea: add as many diagonals from the current vertex handled to those on the stack as possible. current vertex Invariants of iteration: reflex vertices One boundary of the funnel is a polygon edge. The other boundary is a chain of reflex vertices (with interior angles > ) plus one convex vertex (the highest) at bottom of the stack.

Case 1: Next Vertex on Opposite Chain This vertex must be the lower endpoint of the single edge e bounding the chain. u j –4 u j –3 e u j –2 Pop these vertices from the stack. Add diagonals from the current vertex to them (except the bottom one) as they are popped. current vertex u j –1 u j Push the previous top of the stack and the current vertex back onto the stack. u j –1 u j –2 u j –3 u j u j –4 u j –1

Case 2: Next Vertex on the Same Chain u j –5 The vertices that can connect to the current vertex are all on the stack. u j –4 Pop one vertex from the stack. It shares an edge with the current vertex. u j –3 u j –2 u j –1 current vertex u j Pop other vertices from the stack as long as they are visible from the current vertex. Draw a diagonal between each of them and the current vertex. u j –1 u j –2 u j –3 u j u j –4 u j –4 Pushed the last popped vertex back onto the stack followed by the current vertex. u j –5 u j –5

The Triangulation Algorithm TriangulateMonotonePolygon(P) Input: A strictly y-monotone polygon P stored in DCEL D. Output: A triangulation of P stored in D. Merge the vertices on the left and right chains into one sequence sorted in decreasing y-coordinate. (In case there is a tie, the one with smaller x-coordinate comes first.) 2. Push(u , S) Push(u , S) for j  3 to n – 1 do if u and Top(S) are on different chains then while Next(Top(S))  NULL v  Top(S) Pop(S) insert a diagonal from u to v Push(u , S) else Pop(S) while Top(S) is visible from u inside the polygon insert a diagonal between u and v Push the last popped vertex back onto S j j –1 2 1 j

An Example u u u u u Start: u u u u u u u u u u j =3: j =4: u u u u u 1 u 2 u 3 u 2 1 u 4 Start: u 6 u 5 u 7 u 8 u 9 u 10 u 11 u 4 u 3 u 3 j =3: j =4: u 12 u 2 u 2 u 13 u 14 u 1 u 1 u 15 u 16 u 18 u 17 u 4 j =5: u 19 j =6: u 2 u 5 u 5 u 6 u 20 u 1 u 5 u 1

Example (cont’d) u u u u j = 7: u u u u u u u u u u u u u u j =8: 1 u 2 u 3 u 4 j = 7: u 7 u 6 u 6 u 5 u 6 u 5 u 7 u 8 u 9 u 10 u 11 u 8 u 7 u 9 j =8: j =9: u 12 u 7 u 6 u 8 u 13 u 14 u 15 u 16 u 18 u 17 u 11 u 10 j =10: u 10 u 9 u 19 j =11: u 20 u 10 u 8 u 8

Example (Cont’d) u u u u j = 15: u u u u u u u u u j = 16: u j = 17: u 2 u 3 u 4 j = 15: u 15 u 6 u 5 u 10 u 7 u 8 u 9 u 10 u 11 j = 16: u 16 j = 17: u 16 u 15 u 17 u 15 u 12 u 13 u 14 u 10 u 10 u 15 u 16 u 18 u 17 u 18 u 17 u 19 u 18 u 19 j = 18: j = 19: u 20 u 17 u 10 u 17

Removal of Strict y-monotonicity The running time of TriangulateMonotonePolygon is (n). #pushes  2n – 4 ( 2 vertices pushed each of n – 3 iteration steps plus 2 at the beginning) #pops  #pushes What to do if some vertices have the same y-coordinates? Treat them from left to right. The effect of this is equivalent to that of rotating the plane slightly clockwise and then every vertex will have different y coordinate.

Time Complexity of Triangulation 1. Partition a simple polygon into monotone pieces. O(n log n) 2. Triangulate each monotone piece. (n) for all monotone pieces together Theorem A simple polygon can be triangulated in O(n log n) time and O(n) storage.

Triangulation of a Planar Subdivision The algorithm for splitting a polygon into monotone pieces does not use the fact that the polygon was simple. The plane sweep for decomposition of a polygon into monotone pieces takes as input only edges that lie to the left of the interior. This easily generalizes to a planar subdivision in a bounding box. Thus a planar subdivision with n vertices can also be triangulated in O(n log n) time using O(n) storage.