Presentation is loading. Please wait.

Presentation is loading. Please wait.

Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.

Similar presentations


Presentation on theme: "Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik."— Presentation transcript:

1 Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

2 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann2 Triangulation of a convex polygon

3 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann3 l-Monotone Convex polygons are easy to triangulate. Unfortunately the partition into convex pieces is just as difficult as the triangulation. l-monotone l P A simple polygon is called monotone w.r.t. a line l if for any line l´ perpendicular to l the intersection of the polygon with l´ has at most one connected component.

4 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann4 Two steps for triangulation 1. Divide P into y-monotone parts P 1,...,P k 2. Triangulate P 1,...,P k

5 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann5 Five types of vertices = start vertex = end vertex = regular vertex = split vertex = merge vertex

6 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann6 Lemma:A polygon is y-monotone if it has no split vertices or merge vertices. Proof:Suppose P is not y-monotone  there is a horizontal line l that intersects P in more than one connected component. We show that P must have at least one split or merge vertex: pqr P split vertex (a) l r = p P q r´ merge vertex (b) Y-Monotone

7 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann7 Removal of Split and Merge Vertices helper(e j ) is lowest vertex above the sweep line such that the horizontal segment connecting the vertex to e j lies inside P. ejej helper(e j ) ekek vivi e i-1 eiei l ejej ekek vivi vmvm Merge-nodes are split nodes in reverse. v i is the new helper of e j. We would like to connect v i to the highest vertex below the sweep line in between e j and e k

8 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann8 Algorithm: MakeMonotone Input:A simple polygon P stored in a doubly-connected edge list D Output:A partitioning of P into monotone sub-polygons, stored in D Construct a priority queue Q on the vertices of P. Initialize an empty binary search tree T. while Q is not empty do remove the vertex v i with highest priority from Q call appropriate procedure to handle the vertex.

9 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann9 Handling Start Vertices HandleStartVertex(v i ):T = T  {e i }, helper(e i ) = v i vivi eiei

10 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann10 Handling End Vertices HandleEndVertex(v i ):if helper(e i-1 ) is merge vertex then insert diagonal connecting v i to helper(e i-1 ) in D. T = T- {e i-1 } vivi e i-1

11 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann11 Handling Split Vertices HandleSplitVertex(vi) : Search in T to find the edge e j directly left of v i Insert the diagonal connecting v i to helper(e j ) in D. helper(e j ) = v i Insert e i in T and set helper(e i ) to v i vivi eiei ejej

12 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann12 Handling Merge Vertices HandleMergeVertex(v i ) : if helper(e i-1 ) is a merge vertex then Insert diagonal connecting vi to helper(e i-1 ) in D. Delete e i-1 from T. Search in T to find the edge e j left of v i if helper(e j ) is a merge vertex then Insert diagonal connecting v i to helper(e j ) in D. helper(e j ) = v i e i-1 vivi ejej

13 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann13 Handling Regular Vertices HandleRegularVertex(v i ) : if the interior of P lies to the right of v i then if helper(e i-1 ) is a merge vertex then Insert the diagonal connecting v i to helper(e i-1 ) in D Delete e i-1 from T. Insert e i in T and set helper(e i ) to v i. else search in T to find the edge e j left of v i if helper(e j ) is a merge vertex then insert the diagonal connecting v i to helper(e j ) in D helper(e j ) = v i vivi e i-1 eiei

14 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann14 Handling Regular Vertices HandleRegularVertex(v i ) : if the interior of P lies to the right of v i then if helper(e i-1 ) is a merge vertex then Insert the diagonal connecting v i to helper(e i-1 ) in D Delete e i-1 from T. Insert e i in T and set helper(e i ) to v i. else search in T to find the edge e j left of v i if helper(e j ) is a merge vertex then insert the diagonal connecting v i to helper(e j ) in D helper(e j ) = v i vivi ejej

15 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann15 Example ab c d ef g h i jk l m no vThelper a b c d e ! f g h i j ! k l m ! n o

16 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann16 Correctness of MakeMonotone To show: Added segments are valid diagonals. Proof for the segment added in HandleSplitVertex Consider a segment v m v i that is added when v i is reached by HandleSplitVertex. Let e j be the edge to left of v i, and let e k be the edge to right of v i. helper(e j ) = v m when we reach v i. Q ekek ejej vmvm vivi I. v m v i does not intersect an edge of P Consider the quadrilateral Q, there are no vertices of P inside Q, else v m would not be helper of e j. Suppose there would be an edge of P intersecting v m v i then it would have to intersect the horizontal segment connecting v i to e j or v m to e j but this is impossible since e j immediately to the left of v m and v i. II. v m v i does not intersect a previously added diagonal d Since there are no vertices of P inside Q, and d must have both its endpoints above v i, v m v i cannot intersect d.

17 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann17 Monotone Partitioning Theorem: A simple polygon with n vertices can be partitioned into y-monotone polygons in O(n log n) time with an algorithm that uses O(n) storage.

18 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann18 Triangulation of y-monotone Polygons Idea: Process vertices from top to bottom For each vertex v, connect v to all vertices above it and visible via a diagonal, continue with next vertex below v. The algorithm requires a stack. The vertices in the stack build a reflex chain, which is the borderline between the triangulated and not yet triangulated part of the polygon. Two cases when encountering a vertex u j : 1. u j lies on the opposite chain as the reflex vertices on the stack ujuj

19 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann19 Triangulation of y-monotone Polygons 2. u j lies on the same chain as the reflex vertices on the stack Two cases: ujuj ujuj

20 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann20 Implementation 1. S.push(u1), S.push(u2) 2. for j = 3,...,n-1 3. if (side(uj)  side(S.top)) 4. while (S   ) v = S.pop, diag(uj,v) 5. S.push(uj-1) 6. S.push(uj) 7. else S.pop 8. while (diag(S.top, uj) in P) 9. diag(S.top, uj) 10. S.pop 11. S.push(last) 12. S.push(uj) ujuj ujuj

21 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann21 Example 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

22 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann22 Theorems Theorem: A strictly y-monotone polygon with n vertices can be triangulated in O(n) time. Theorem: A simple polygon with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage. Theorem: A planar subdivision with n vertices in total can be triangulated in O(n log n) time with an algorithm that uses O(n) storage.


Download ppt "Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik."

Similar presentations


Ads by Google