1 / 59

POLYGON TRIANGULATION

POLYGON TRIANGULATION. THE ART GALERY PROBLEM. SİNEM GETİR 2008-2009 COMPUTER GRAPHIC SEMINAR. FEBRUARY 4, 2009 . CONTENTS. Guarding and triangulations Can we do better? 3-Coloring The art galery theorem Partitioning a polygon into monotone pieces Triangulating a Monotone polygon .

clover
Télécharger la présentation

POLYGON TRIANGULATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. POLYGON TRIANGULATION THE ART GALERY PROBLEM SİNEM GETİR 2008-2009 COMPUTER GRAPHIC SEMINAR FEBRUARY 4, 2009

  2. CONTENTS • Guarding and triangulations • Can we do better? • 3-Coloring • The art galery theorem • Partitioning a polygon into monotone pieces • Triangulating a Monotone polygon

  3. The Art Gallery Problem camera How many cameras are needed to guard a gallery and How should they be placed?

  4. 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

  5. Guards have a viewport of 360° • A polygon is completely guarded, if every point within the polygon is guarded by at least one of the watchmen

  6. Simple Polygon Model Model the art gallery as a region bounded by some simple polygon (no self-crossing). Regions with holes are not allowed. convex polygon one camera an arbitrary n-gon (n vertices) Bad news: finding the minimum number of cameras for a given polygon is NP-hard (exponential time).

  7. Triangulation • Let P a simple polygon with n vertices • We first decompose P into pieces that are easy to guard, namely triangles. • DEFİNİTİON:A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals is called a triangulation of the polygon. • Triangulations are usually NOT unique • Many applications: visibility, robotics, mesh generation, point location etc.

  8. Triangulation To make things easier, we decompose a polygon into pieces that are easy to guard. Guard the polygon by placing a camera in every triangle … Draw diagonals between pair of vertices. an open line segment that connects two vertices and lie in the interior of the polygon.

  9. w v u THE QUESTION… Does every simple polygon admit a triangulation? If yes, what is the number of triangles? Does any triangulation lead to the same number of triangles?

  10. Proof By induction. Existence uw in the interior of P it is a diagonal. w P v  Otherwise, the triangle determined by u, v, w contains at least one vertex. Let v be the one closest to v. Then vv is a diagonal. w v v u u Theorem 1 Every simple polygon has a triangulation. Any triangulation of a simple polygon with n vertices consists of exactly n – 2 triangles. Trivial for n = 3. Assume true for all m < n. Let v be the leftmost vertex and u and w its two neighbors. The diagonal splits the polygon into two (which by induction can be triangulated).

  11. Vertices defining the diagonal occur in each subpolygon once. # triangles = n – 2 Other vertices of P each occurs in exactly on one subpolygon. Proof Any diagonal splits P into two simple polygons with k and m vertices, respectively. By induction these two subpolygons can be triangulated. They are decomposed into k – 2 and m – 2 triangles, resp. Thus k + m = n + 2. By induction, the triangulation of P has (k – 2) + (m – 2) = n – 2 triangles.

  12. Theorem1 shows that any simple polygon with n vertices can be guarded with n-2 cameras. But placing a camera inside every triangle seems OVERKILL. A camera on a diagonal guards two triangles.  # cameras can be reduced to roughly n/2. A vertex is adjacent to many triangles. So placing cameras at vertices can do even better …

  13. 3-Coloring Idea:Select a set of vertices, such that any triangle has at least one selected vertex. Assign each vertex a color: pink, green, oryellow. Any two vertices connected by an edge or a diagonal must be assigned different colors. Thus the vertices of every triangle will be in three different colors. If 3-coloring exists, place cameras at all vertices of the same color. Choose the smallest color class to place the cameras. n/3 cameras.

  14. A 3-Coloring Algorithm A 3-coloring can be found through a graph traversal (such as DFS). During DFS, maintain the invariant: All polygon vertices of encountered triangles have been colored such that no adjacent two have the same color. u Start DFS at any node of G. Color the three vertices of the corresponding triangle. v Suppose node v is visited from u.  Their triangles T(v) and T(u) are adjacent. Only one vertex of T(v) is not colored.  Its color is uniquely determined. Since G is a tree, the other nodes adjacent to v have not been visited yet. Otherwise there exists a cycle (which contradicts that G is a tree.)  Apply the color to v.

  15. Art gallery theorem Theorem: For a simple polygon with n vertices, n/3 cameras are occasionally necessary and always sufficient to have every point in the polygon visible from at least one of the cameras. Can we do better?

  16. THE WORST CASE SCENARIO…

  17. A Worst Case A triangulated polygon can always be 3-colored.  Any simple polygon can be guarded with n/3 cameras. a n/3 prongs There exists no position at which a camera can oversee two prongs. n/3 cameras are needed. The 3-coloring approach is optimal in the worst case.

  18. 1.Triangulate a simple polygon with a fast algorithm. DCEL representation for the simple polygon so we can visit a neighbor from a triangle in constant time. 2. Generate a 3-coloring by DFS (as presented earlier). 3. Take the smallest color class to place the cameras. Solution to the Art Gallery Problem

  19. THEOREM • Let P be a simple polygon with n vertices.A set of [n/3] camera positions in P such that any point inside P is visible from at least one of the cameras can be computed in O(n logn) time.

  20. PARTITIONING A POLYGON INTO MONOTONE PİECES • We have just seen that a triangulation of P always exists.the proof of that theorem is constructive and leads to a recursive triangulation algorithm: • Find a diagonal and triuanglate the two resulting subpolygons recursively.

  21. …  The triangulation algorithm will take quadratic time in the worst case. • Can we do better?

  22. Convex polygon • Pick one vertex of the Polygon and draw diagonals From this vertex to all other vertices except its neighbors. This takes only linear time.

  23. For a non-convex polygon unfortunately ,it is as difficult to partition a polygon into convex pieces as it is to trianglate it.Therefore we shall decompose P into so-called monotone pieces.

  24. Monotone polygon • A polygonP in the plane is called monotone with respect to a straight line L, if every line orthogonal to L intersects P at most twice.

  25. Line sweep(top down) • Vertices where the direction changes downward<> are called turn vertices. • To have y-monotone pieces ,we need to get rid of turn vertices: • When we encounter a turn vertex,it might be necessary to introduce a diagonal and split the polygon into pieces • We will not add diagonals at all turn vertices

  26. Types of Turn Vertices If we want to define the different types of turn vertices carefully,we should pay special attention to vertices with equal y-coordinate.We do this by defining the notions of “below” and “above” as follows ; a point p is below another point q if • 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°

  27. VERTEX ONTOLOGY

  28. The split and merge vertices are sources of local non-monotonicity.The following stronger stament is true. • LEMMA:A polygon is y-monotone if it has no split vertices or merge vertices.

  29. Adding diagonals * The partition p into y-monotone pieces , get rid of split and merge vertices • Add a diagonal going upward each split vertex. • Add a diagonal going downward from each merge vertex. * Where do the edges go?

  30. Helpers • Let helper helper(ej) be the lowest vertex above the sweep-line • Such that the horizontal segment connecting the vertex to ej lies inside P

  31. Removing Split Vertices • For a split vertex vi ,let be the edge immediately to the left of it. • Add a diagonal from vi to helper ej

  32. Removing merge vertex • For a merge vertex vi let ej be edge immediately to the left of it • vi becomes helper(ej ) ones we reach it • Whenever the helper(ej ) is replaced by some vertex vm ,add a diagonal from vm to vi • If vi is never replaced as helper(ej ), we can connect it to the lower endpoint of ej ..

  33. Removing Split/Merge Vertices • v1 … vn: a counter-clock enumeration of vertices of P • e1 … en: a set of edges of P, where ei = segment (vi , vi+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).

  34. THE ALGORITHM…

  35. 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 vi with the highest priority from Q 5. Call the appropriate procedure to handle the vertex, depending on its type

  36. HandleStartVertex(Vi) 1. Insert ei in T and set helper(ei) to vi

  37. HandleEndVertex(Vi) • if helper(ei-1) is a merge vertex 2. then Insert diagonal connecting vi to helper(ei-1) in D 3. Delete ei-1 from T

  38. HandleSplitVertex(Vi) 1. Search in T to find the edge ej directly left of vi 2. Insert diagonal connecting vi to helper(ej ) in D 3. helper(ej ) vi 4. Insert ei in T and set helper(ei ) to vi

  39. HandleMergeVertex(Vi) 1. if helper(ei-1) is a merge vertex 2. then Insert diagonal connecting vi to helper(ei-1) in D 3. Delete ei-1 from T 4.Search in T to find the edge ejej directly left of vi 5.if helper(ej) is a merge vertex 6. then Insert diagonal connecting vi to helper(ej) in D 7. helper(ej ) vi

  40. HandleRegularVertex(Vi) 1. if the interior of P lies to the right of vi 2. then if helper(ei-1) is a merge vertex 3. then Insert diag. connect vi to helper(ei-1) in D 4. Delete ei-1 from T 5. Insert ei in T and set helper(ei) to vi 6.else Search in T to find the edge ej directly left of vi 5.if helper(ej) is a merge vertex 6. then Insert diag. connect vi to helper(ej) in D 7. helper(ej ) vi

  41. 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)

  42. An attempt was made to triangulate the following polygon, this time with respect to the horizontal, can you guess why the triangulation wasn't successful? • Monotonic triangulation that failed because the polygon is not monotonic

  43. After a slight modification to the polygon (it doesn't look like a donkey anymore), the polygon now looks like this and can be triangulated using the concept. A successful monotonic triangulation of the modified polygon

  44. LEMMA • Algorithm MAKE MONOTONE adds set of non-intersecting diagonals that partitions P into monotone subpolygons.

  45. Proof: • We shall prove for the segment added in HANDLE-SPLİT-VERTEX ; the proof for the segments added in HANDLE-END-VERTEX,HANDLE-REGULAR-VERTEX,and HANDLE-MERGE-VERTEX is similar. • We assume that no two vertices have the same y-coordinate.

More Related