730 likes | 1.19k Views
Polygon Triangulation. 전진우 손명 배. Art Gallery Problem. Want to cover all areas Assume that the art gallery is a simple polygon Does not intersect itself How many cameras do we need? Where do we put it? Getting an exact solution is NP-hard We just want to get a lower bound. Triangulation.
E N D
Polygon Triangulation 전진우 손명배
Art Gallery Problem • Want to cover all areas • Assume that the art galleryis a simple polygon Does not intersect itself • How many cameras do we need? • Where do we put it? • Getting an exact solution is NP-hard We just want to get a lower bound
Triangulation • Easy to guard • Draw diagonals An open line segment that connects two vertices of P and lies in the interior of P • A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals is called a triangulation of the polygon
Triangulation • Thm 3.1 Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists of exactly n−2 triangles. • Induction on n • n = 3: Trivial • n > 3: Assume that the theorem is true for all m<n ……
Triangulation • Pick a vertex v and neighboringvertices w and u. Draw • Case 1: vwu does not contain anyvertices Then is a diagonal; P consists of vwuand the rest is triangulated inton – 3 triangles. • Case 2: vwu contains some vertices Let v’ be the farthest point from .Then is a diagonal. Why?If intersects any edges, one of itsendpoint is farther than v’ ↯
Triangulation Methods • Recursive triangulation algorithm • Based on the argument stated previously • Draw a line segment and find the diagonal • O(n2) at worst • Split into convex pieces and triangulate • Easy to triangulate - just draw diagonals froma single vertex • Hard to split the polygon into convex pieces • Split into monotone pieces and triangulate • A little bit harder to triangulate, but O(n) anyway • Takes O(nlogn) to split the polygon into monotonepieces
Monotone Polygon • A simple polygon is called monotonicwith respect to l if for any line l’perpendicular to l, the intersectionof the polygon with l’ is connected. • If we walk from a topmost to abottommost vertex along one sideboundary chain, then we alwaysmove downwards or horizontally,never upwards.
Monotone Polygon • Split the polygon by getting rid of turn vertex • Walk through either left orright chain from topmostto downmost vertex • Our walking direction changeson turn vertex (either downward to upwardor vice versa)
Monotone Polygon v5 v3 • Regular vertex When v is none of following types • Start vertex When v is above its neighbors interior angle < π • End vertex When v is below its neighbors interior angle < π • Split vertex When v is above its neighbors interior angle > π • Merge vertex When v is below its neighbors interior angle >π v4 v6 v1 v9 v7 v2 v8 v14 v10 v12 v15 v11 v13
Monotone Polygon • Lemma 3.4 A polygon is y-monotone if it has no split vertices or merge vertices. Suppose P is not monotone. Then there’s a horizontal line l that intersects P in more than one connected components. ∴ Either a split vertex or a merge vertex exists
Monotone Polygon • How to get rid of split vertex and merge vertex? Add diagonal upward @ split vertex / downward @ merge vertex • Use plane sweep method!
Monotone Polygon • Sweep line goes from topmost vertex to bottommost vertex • Event points: every vertices No more addition/removal on event queueWe can just sort vertices on y coord in O(nlogn) and use it • Add diagonals to split / merge vertices along sweep
Plane Sweep • Handling a split vertex vi • Find edge located on left andright of vi – ej and ek • Choose the lowest vertexbetween ej and ek • We call it the helper of ej • Draw a diagonal to the helper • Formal defintion: helper(ej) is the lowest vertex above sweep line s.t.the horizontal segment connecting the vertex to ejlies inside P
Plane Sweep • Handling a merge vertex vi Draw a diagonal toward some vertexvm which is lower than the sweep line?? • vmis a vertex whose left edge (ej)has its helper vi When we meet vm, draw a diagonal It is done when
Plane Sweep • We need to know the left edge (ej) of vertex and its helper. Only left edges are needed; store the edges whose interior toward P is right side. • Save the list of left edges intersecting with sweep line • Use dynamic binary search tree T • Save a helper for each edges • Output should be the divided subpolygons with doubly connected edge list.
Event Points v5 • Start vertex When v is above its neighbors interior angle < π e5
Event Points • End vertex When v is below its neighbors interior angle < π v6 e8 v9
Event Points • Split vertex When v is above its neighbors interior angle > π v9 v8 v14 e9 e14 v11 v13
Event Points • Merge vertex When v is below its neighbors interior angle >π v7 v9 v2 e7 v8 e9
Event Points • Regular vertex When v is none of following types v4 e5 v6 e6
Event Points • Regular vertex When v is none of following types v12 v16 e12
Monotone Polygon • Pretty standard line sweep algorithm
Monotone Polygon • Lemma 3.5 Algorithm MakeMonotoneadds a set of non-intersecting diagonals that partitions P into monotone subpolygons. • It is easy to see that P is partitioned in a way that no split/merge vertices exists ∴By Lemma 3.4, it is monotone • But, are diagonals valid? Each of them should not intersect with another or edges • We’ll prove that for HandleSplitVertex Rest are similar
Monotone Polygon • Consider a segment added by HandleSplitVertex() • Let Q be the quadrilateral bounded by ej, ek, vi, vm There are no vertices in Q; otherwise vm couldn’t be the helper of ej • Any “edge” that intersects should go through horizontalsegment that connects ej to eithervm or vi – contradicting that ej liesimmediately to the left for them. • For previously added diagonals,their endpoints should be over vi,and over Q (as no vertices are in Q) It can’t intersect
Analysis • Priority queue construction: O(n) By sort: O(nlogn) • Total n events: • At most one insertion / deletion on T – O(logn) • At most two diagonal insertion on D – O(1) • Space complexity: O(n) • At most n (|V|) items on Q • At most n (|E|) items on T • Thm3.6 A simple polygon with n vertices can be partitioned into y-monotone polygons in O(nlogn) time with an algorithm that uses O(n) storage
Example v5
Example v3 e5
Example e3 e5 v4
Example e5 v6
Example v7 e6
Example v1 e7
Example v9 e1 e7
Example e1 e7 v2 e9
Example e7 e9 v8
Example e9 v14
Example e9 v15 e14
Example e9 v10
Example e10 v12
Example e10 v11
Example v13
So Far… • Our ultimate goal is to solve thepolygon triangulation, in orderto solve the art gallery problem • And for that, we’ve monotonizedthe polygon to ease the problem Done in O(nlogn) • Now it’s time to triangulateeach monotone polygons! Done in O(n)
Outline of Triangulation • Let polygon P be a y-monotone with n vertices • We always go down when we walk on the left or right boundary chain of P • Stack contains vertices that have been encountered but may still need more diagonals • Add diagonals with vertices in stack whenever this is possible
Stack • Stack stores vertices that have been visited but not yet connected with a diagonal • is the bottom and is the top of the stack • Stack must meet the two invariant conditions • The vertices on the stack lie on the same chain on the boundary of P • If i ≥ 3, for 1 ≤ j ≤ i - 2
Initialization • Sort N vertices of monotone polygon P in order by decreasing y coordinate • If two vertices have the same y-coordinate, then the leftmost one is handled first • 𝑢1, 𝑢2, …, 𝑢𝑁be the sorted sequence of vertices y(𝑢1)>y(𝑢2)>…>y(𝑢𝑁) • Edge 𝑢𝑖 𝑢𝑗is an edge of monotone polygon P
Cases • Case 1 : u is adjacent to v1 but not vi :
Cases • Case 2 : u is adjacent to vi but not v1
Cases • Case 3 : u is adjacent to both v1 and vi
Example • Sorting on decreasing y-coordinate • Stack Empty • Diagonal Empty u1 u2 u3 u4 u5 u6 u7 u8 u9 u10