Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation (Naive)

Similar presentations


Presentation on theme: "Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation (Naive)"— Presentation transcript:

1 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation (Naive)

2 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of a convex polygon

3 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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´ is connected (y-monotone, if l = y-axis). Observation: if P is y-monotone then P Consists of two y-monotone chains.

4 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Two steps for triangulation 1. Divide P into y-monotone parts P 1,...,P k 2. Triangulate P 1,...,P k

5 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Split and merge vertices = start vertex = end vertex = regular vertex = split vertex = merge vertex

6 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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)

7 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Five types of vertices = start vertex = end vertex = regular vertex = split vertex = merge vertex

8 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Removal of Split and Merge nodes 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

9 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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

10 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Example ab c d ef g h i jk l m no vThelper a ad ad = a b ad,bc bc = b c ad,ce ce = c d ce ce = d e ! ei ei = e f ei g ei,gl gl = g h ei,gl i gl gl = i j ! gl,jo jo = gl = j k gl l ln ln = l m ! ln,mo ln = mo = m n mo o

11 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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.

12 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Handling start, end and split vertices HandleStartVertex(v i ):T = T  {e i }, helper(e i ) = v i vivi i e

13 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Handling start, end and split vertices HandleEndVertex(v i ):if (helper(e i-i ) is merge vertex) then insert diagonal connecting v i to helper(e i-1 ) in D. T = T-{e i-1 } e i- 1 vivi

14 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Handling start, end and split vertices HandleSplitVertex(v i ): 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 ejej eiei

15 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Handling merge vertices HandleMergeVertex(v i ) : if helper(e i-1 ) is a merge vertex then Insert diagonal connecting v i 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 vivi e i- 1 ejej

16 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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

17 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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

18 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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.

19 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of y-monotone Polygon reflex chain: a polygonal chain is called a reflex chain, if the vertices v 2 thru v n-1 are concave. vnvn v1v1

20 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of y-monotone Polygon Idea: Process vertices in decreasing y-order; add as many diagonals as possible Invariant: Vertices in stack form a reflex chain When processing next vertex v: Case 1: v is on same side as top vertex in stack Case 2: v is on opposite side as top vertex in stack

21 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of y-monotone Polygon Case 1: v is on same side as top vertex in stack

22 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of y-monotone Polygon Case 1: v is on same side as top vertex in stack

23 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation of y-monotone Polygon Case 2: v is on opposite side as top vertex in stack

24 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann 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

25 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Implementation 1.S.push(u 1 ), S.push(u 2 ) 2. for j = 3,...,n-1 3. if (side(u j )  side(S.top)) 4. while (S   ) v = S.pop, diag(u j,v) 5. S.push(u j-1 ) 6. S.push(u j ) 7. else 8. while (diag(S.top, u j ) in P) 9. diag(S.top, u j ) 10. S.pop 11. S.push(last) 12. S.push(u j ) Theorem: time O(n) Proof: number of pops < number of pushes

26 Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Theorem 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 "Lecture 3: Polygon Triangulation Computational Geometry Prof. Dr. Th. Ottmann Triangulation (Naive)"

Similar presentations


Ads by Google