Download presentation
Presentation is loading. Please wait.
Published byByron Hicks Modified over 10 years ago
1
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing
2
UNC Chapel Hill M. C. Lin Guarding an Art Gallery Place as few cameras as possible Each part of the gallery must be visible to at least one of them Problems: how many cameras and where should they be located?
3
UNC Chapel Hill M. C. Lin Transform to a Geometric Problem Floor plan may be sufficient and can be approximated as a simple polygon. – A simple polygon is a region enclosed by single closed polygonal chain that doesn’t self-intersect A camera’s position corresponds to a point in the polygon A camera sees those points in the polygon to which it can be connected with an open segment that lies in the interior of the polygon –assuming we have omni-cam that sees all directions
4
UNC Chapel Hill M. C. Lin Problem Analysis A convex polygon can always be guarded by 1 Bound the number of cameras needed in terms of n, number of vertices in the polygon 2 polygons with the same number of vertices may not be equally easy to guard Find the minimum number of cameras for a specific polygon is NP-hard
5
UNC Chapel Hill M. C. Lin Triangulation of a Polygon Definition: A decomposition of a polygon into triangles by a maximal set of non- intersecting diagonals Triangulations are usually NOT unique Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists of exactly n-2 triangles
6
UNC Chapel Hill M. C. Lin Observations We can guard a gallery by n-2 cameras We can do better by placing cameras at the diagonals, then we only need n/2 Even better by placing cameras at vertices of the polygons => n/3 needed by using 3- coloring scheme of a triangulated polygon (ex) comb-shape like polygon –3-coloring of a polygon always exists
7
UNC Chapel Hill M. C. Lin Polygon Triangulations Find a diagonal and triangulate the two resulting subpolygons recursively: O(n 2 ) Triangulation of a convex polygon: O(n) First decompose a nonconvex polygon into convex pieces and then triangulate the pieces. But, it is as hard to do a convex decomposition as to triangulate the polygon => Decompose a polygon into monotone pieces
8
UNC Chapel Hill M. C. Lin Partition a Polygon into Monotone Pieces A simple polygon is monotone w.r.t. a line l if for any line l ’ perpendicular to l the intersection of the polygon with l ’ is connected Property: If we walk from a topmost to a bottom- most vertex along the left (or right) boundary chain, then we always move downwards or horizontally, never upwards Strategy to triangulate P: By first partition P into y-monotone pieces, then triangulate the pieces
9
UNC Chapel Hill M. C. Lin Turn Vertex Imagine walking from the topmost vertex of P to the bottommost vertex on the left/right boundary chain…... Definition: A vertex where the direction in which we walk switches from downward to upward or vice versa To partition a polygon into y-monotone pieces, get rid of turn vertices by adding diagonals
10
UNC Chapel Hill M. C. Lin Types of Turn Vertices Start Vertex - its two neighbors lie below it and the interior angle < 180° End Vertex - its two neighbors lie above it and the interior angle < 180° Split Vertex - its two neighbors lie below it and the interior angle > 180° Merge Vertex - its two neighbors lie above it and the interior angle > 180°
11
UNC Chapel Hill M. C. Lin Observations The split and merge vertices are sources of local non-monotonicity A polygon is y-monotone if it has no split or merge vertices Use the plane-sweep method to remove split & merge vertices
12
UNC Chapel Hill M. C. Lin Removing Split/Merge Vertices v 1 … v n : a counter-clock enumeration of vertices of P e 1 … e n : a set of edges of P, where e i = segment (v i, v i+1 ) Events are stored in event queue, ordered by y-coord. If a split vertex, connect it to the lowest vertex (helper of its left edge) between the edges to its left and right If a merge vertex, connect it to the highest vertex between the edges to its left and right Store the edges (and their helpers) of P in the leaves of dynamic binary search tree T, left-to-right order reflects in order of leaves. Helpers may be replaced. Store only edges that have P to their right (or the left edges).
13
UNC Chapel Hill M. C. Lin 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 1. Construct a priority queue Q on the vertices of P, using their y- coordinates as priority. If two points have the same y- coordinates, the one with smaller x has higher priority 2. Initialize an empty binary search tree T 3. while Q is not empty 4. do Remove v i with the highest priority from Q 5. Call the appropriate procedure to handle the vertex, depending on its type
14
UNC Chapel Hill M. C. Lin HandleStartVertex(V i ) 1. Insert e i in T and set helper(e i ) to v i
15
UNC Chapel Hill M. C. Lin HandleEndVertex(V i ) 1. if helper(e i-1 ) is a merge vertex 2. then Insert diagonal connecting v i to helper(e i-1 ) in D 3. Delete e i-1 from T
16
UNC Chapel Hill M. C. Lin HandleSplitVertex(V i ) 1. Search in T to find the edge e j directly left of v i 2. Insert diagonal connecting v i to helper(e j ) in D 3. helper(e j ) v i 4. Insert e i in T and set helper(e i ) to v i
17
UNC Chapel Hill M. C. Lin HandleMergeVertex(V i ) 1. if helper(e i-1 ) is a merge vertex 2. then Insert diagonal connecting v i to helper(e i-1 ) in D 3. Delete e i-1 from T 4. Search in T to find the edge e j directly left of v i 5. if helper(e j ) is a merge vertex 6. then Insert diagonal connecting v i to helper(e j ) in D 7. helper(e j ) v i
18
UNC Chapel Hill M. C. Lin HandleRegularVertex(V i ) 1. if the interior of P lies to the right of v i 2. then if helper(e i-1 ) is a merge vertex 3. then Insert diag. connect v i to helper(e i-1 ) in D 4. Delete e i-1 from T 5. Insert e i in T and set helper(e i ) to v i 6. else Search in T to find the edge e j directly left of v i 5. if helper(e j ) is a merge vertex 6. then Insert diag. connect v i to helper(e j ) in D 7. helper(e j ) v i
19
UNC Chapel Hill M. C. Lin Partitioning Algorithm Analysis Construct priority queue: O(n) Initialize T: O(1) Handle an event: O(log n) –one operation on Q: O(logn) –at most 1 query, 1 insertion & 1 deletion on T : O(logn) –insert at most 2 diagonals into D : O(1) Total run time: O(n log n) Storage: O(n)
20
UNC Chapel Hill M. C. Lin Triangulate a Monotone Polygon Order the vertices in decreasing y-coordinates Initialize an empty stack S ; later it contains vertices that have been encountered When handling a vertex, add as many diagonals from it to vertices on S as possible Lowest vertex, encountered last, is on top of S The part not yet triangulated looks like a funnel This funnel is an invariant of the algorithm –consisted of a singe edge & a chain of reflex vertices –only the highest vertex (at the bottom of S ) is convex
21
UNC Chapel Hill M. C. Lin Next Vertex V j to be Handled On the single edge side –must be the lower end point of the edge: add diagonals to all reflex edges, except last one. –This vertex and first are pushed back to stack On the chain of reflex vertices Case 1 –pop one; this one is already connected to V j –pop vertices from stack till not possible –push the last one and V j back Case 2 –pot & push the unable-to-connect one and push V j
22
UNC Chapel Hill M. C. Lin TriangulateMontonePolygon(P) Input: A strictly y-monotone polygon P stored in a d.-c. e. list D Output: A triangulation of P stored in doubly-connected edge list D 1. Merge the vertices on the left and right chains of P into one sequence, sorted on decreasing y-coordinate, with the leftmost comes first. Let u 1...u n denote sorted sequence 2. Push u 1 and u 2 onto the stack S 3. for j 3 to n 1 4. do if u j and vertex on top of S are on different chains 5. then Pop all vertices from S 6. Insert into D a diagonal from u j to each popped vertex, except the last one 7. Push u j-1 and u j onto S
23
UNC Chapel Hill M. C. Lin TriangulateMontonePolygon(P) 8. else Pop one vertex from S 9. Pop the other vertices from S as long as the diagonals from u j to them are inside P. Insert these diagonals into D. Push the last vertex that has been popped back onto S. 10. Push u j onto S 11. Add diagonals from u n to all stack vertices except the first and last one.
24
UNC Chapel Hill M. C. Lin Triangulation Algorithm Analysis A strictly y-montone polygon with n vertices can be triangulated in linear time A simple polygon with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage A planar subdivision with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.