Presentation is loading. Please wait.

Presentation is loading. Please wait.

Polygon Triangulation

Similar presentations


Presentation on theme: "Polygon Triangulation"— Presentation transcript:

1 Polygon Triangulation
전진우 손명배

2 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 Simple polygon: a polygon that does not intersect itself. Num. of camera depends on the complexity of polygon, which means that it depends on n.

3 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 Why maximal set: colinear vertex 3개가 있을 경우, “triangle”을 만족해도 삼각형의 edge에 vertex가 박혀있는 경우가 있다. 그런 경우 방지용.

4 Triangulation Thm 3.1 Induction on n
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 ……

5 Triangulation Pick a vertex v and neighboring vertices w and u. Draw 𝑤𝑢 . Case 1: vwu does not contain any vertices Then 𝑤𝑢 is a diagonal; P consists of vwu and the rest is triangulated into n – 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 its endpoint is farther than v’ ↯ Case 2: rest is the same; vv’ separates polygon into two part; whose sum of number of triangles after triangulation is n – 2

6 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 from a 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 monotone pieces Convex split부터가 triangulation에 기반하므로 cyclic reference

7 Monotone Polygon A simple polygon is called monotonic with respect to l if for any line l’ perpendicular to l, the intersection of the polygon with l’ is connected. If we walk from a topmost to a bottommost vertex along one side boundary chain, then we always move downwards or horizontally, never upwards.

8 Monotone Polygon Split the polygon by getting rid of turn vertex
Walk through either left or right chain from topmost to downmost vertex Our walking direction changes on turn vertex (either downward to upward or vice versa)

9 Monotone Polygon Regular vertex Start vertex End vertex Split 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 Split vertex interior angle > π Merge vertex v4 v6 v1 v9 v7 v2 v8 v14 v10 v12 v15 For vertices who resides on same y coord, we make the definition of “above” and “below” to be ordered by x coord as well, like what happens when P is slightly turned clockwise. Why “split” and “merge”? We’re going to use sweep line algorithm – sweep line is “splitted” and “merged” at those places. v11 v13

10 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 Choose l s.t. leftmost component is a segment Let pq be that segment. If we traverse upward from q, and meet l at some point r s.t. p!=r, then there should be a highest vertex located in path from q to r which is a split vertex If p = r, go downward and lowest vertex is a merge vertex.

11 Monotone Polygon How to get rid of split vertex and merge vertex?
Add diagonal split vertex / merge vertex Use plane sweep method!

12 Monotone Polygon Let 𝑣 1 , 𝑣 2 , …, 𝑣 𝑛 be a counterclockwise enumeration of the vertices, and 𝑒 1 , …, 𝑒 𝑛 be a enumeration of the edges along 𝑣 1 ,…, 𝑣 𝑛 starting from 𝑣 1 𝑣 2 Sweep line goes from topmost vertex to bottommost vertex Event points: every vertices No more addition/removal on event queue We can just sort vertices on y coord in O(nlogn) and use it Add diagonals to split / merge vertices along sweep As stated above, points with same y coord is sorted in such “above”/”below” condition

13 Plane Sweep Handling a split vertex vi
Find edge located on left and right of vi – ej and ek Choose the lowest vertex between 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 ej lies inside P

14 Plane Sweep Handling a merge vertex vi
Draw a diagonal toward some vertex vm which is lower than the sweep line?? vm is a vertex whose left edge (ej) has its helper vi When we meet vm, draw a diagonal It is done when

15 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. We also assume that initial input was also doubly connected edge list.

16 Event Points Start vertex When v is above its neighbors
interior angle < π e5

17 Event Points End vertex When v is below its neighbors
interior angle < π v6 e8 이전 예제에서는 helper가 merge vertex인 경우가 없어 예제를 만들었습니다 v9

18 Event Points Split vertex When v is above its neighbors
interior angle > π v9 v8 v14 e9 e14 v11 v13

19 Event Points Merge vertex When v is below its neighbors
interior angle > π v9 v7 v2 e7 e9 v8

20 Event Points Regular vertex When v is none of following types v4 e5 v6
Case 1. Left vertex

21 Event Points Regular vertex When v is none of following types v12 v16
Case 2. Right vertex

22 Monotone Polygon Pretty standard line sweep algorithm
As I told above, you can just sort the list of vertices instead of using PriorityQ

23 Monotone Polygon Lemma 3.5
Algorithm MakeMonotone adds 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

24 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 horizontal segment that connects ej to either vm or vi – contradicting that ej lies immediately 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 𝑣 𝑚 𝑣 𝑖 ej: left edge, ek: right edge

25 Analysis Priority queue construction: O(n) Total n events:
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 Thm 3.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

26 Example v5

27 Example v3 e5

28 Example e3 e5 v4

29 Example e5 v6

30 Example v7 e6

31 Example v1 e7

32 Example v9 e7 e1

33 Example e7 e1 v2 e9

34 Example e7 e9 v8

35 Example e9 v14

36 Example e9 v15 e14

37 Example e9 v10

38 Example e10 v12

39 Example e10 v11

40 Example v13

41 Example

42 So Far… Our ultimate goal is to solve the polygon triangulation, in order to solve the art gallery problem And for that, we’ve monotonized the polygon to ease the problem Done in O(nlogn) Now it’s time to triangulate each monotone polygons! Done in O(n)

43 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

44 Stack Stack stores vertices that have been visited but not yet connected with a diagonal 𝑣 1 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, ∠ 𝑣 𝑗 𝑣 𝑗+1 𝑣 𝑗+2 ≥𝜋 for 1 ≤ j ≤ i - 2

45 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

46 Cases Case 1 : u is adjacent to v1 but not vi :

47 Cases Case 2 : u is adjacent to vi but not v1

48 Cases Case 3 : u is adjacent to both v1 and vi

49 Pseudocode

50 Example Sorting on decreasing y-coordinate Stack Empty Diagonal u1 u2

51 Example Initialization push u1 and u2 onto stack v1 v2

52 Example u3 : case 2 push u3 v1 v2 u3

53 Example u4 : case 2 push u4 v1 v2 v3 u4

54 Example u5 : case 1 pop v1, v2, v3, v4 push v4, u5
add diagonal 𝑢 5 𝑣 2 , 𝑢 5 𝑣 3 , 𝑢 5 𝑣 4 v1 v2 v3 v4 u5 v1 v2

55 Example u6 : case 2 u6v2v1 < π add diagonal 𝑢 6 𝑣 1 pop v2 push u6
V1, v2, u6이 꺽엿으니까

56 Example u7 : case 2 u7v2v1 > π push u7 v1 v2 u7 V1, v2, u6이 꺽엿으니까

57 Example u8 : case 2 u8v3v2 > π push u8 v1 v2 V1, v2, u6이 꺽엿으니까 v3

58 Example u9 : case 2 u9v4v3 < π add 𝑢9𝑣3 , pop v4 u9v3v2 < π
push u9 v1 v2 v3 u9 v1 v2 v3 v4 u9 v1 v2 v3 V1, v2, u6이 꺽엿으니까

59 Example u10 : case 3 add 𝑢 10 𝑣 2 exit v1 v2 v3 V1, v2, u6이 꺽엿으니까

60 Analysis Thm 3.7 A strictly y-monotone polygon with n vertices can be triangulated in linear time Proof Step 1 takes linear time Step 2 takes constant time For loop is executed n-3 times One execution may take linear time At most two vertices are pushed at every execution total number of pushes : 2n – 4 Number of pops cannot exceed the number of pushes One execution may take linear time -> pop하고 push하는 한번의 for문이 동작하는 과정을 의미 2m-4 : 처음 2개를 push한 것까지 포함

61 For Planar Subdivision
Thm 3.8 A simple polygon with n vertices can be triangulated in O(nlogn) time with an algorithm that uses O(n) storage Thm 3.9 A planar subdivision with n vertices in total can be triangulated in O(nlogn) time with an algorithm that uses O(n) storage 증명하기.. 각각 증명 과정 너놓고 3페이지로 쪼개기도 가능. 3.7 책의 내용 3.8 85 Polygon cutting theorem Decompose a polygon into monotone pieces -> o(nlogn) time, o(n) space split subdivision into monotone pices (Trapezoid??)

62 3-coloring Recall 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. Thus n-2 cameras needed- any better solution? Place camera on a vertex v: every triangle that shares v will be covered! Lower bound: 𝑛/3 How to get this bound? v

63 3-coloring Do 3-coloring on triangulation - assign three colors B/G/W
No neighboring two vertices have same color In triangle, all three vertices have different color! Choose a color, then put a camera on each vertex with that color (e.g. Black) The fewest number of vertices is no more than 𝑛/3 Do we have 3-colorings?

64 3-coloring We can visit each triangle in DFS order on the dual graph
In simple polygon, notice that the dual graph is a tree Then we can always make a valid assignment of 3-coloring on every triangle

65 Art Gallery Theorem Is 𝒏/𝟑 tight? Yes.
No single camera can see two prongs at a time! Thm 3.2 For a simple polygon with n vertices, 𝑛/3 cameras are occasionally necessary and always sufficient to have every point in the polygon visible from at least one of the cameras.

66 Art Gallery Theorem 3-coloring takes one DFS which is done in O(n)
We claim that the triangulation of a simple polygon takes O(nlogn) time If it is true, then… Thm 3.3 Let P be a simple polygon with n vertices. A set of 𝑛/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(nlogn)time. O(nlogn) is not tight, though the optimal method (O(n)) is complex as hell and practically slower.

67 Reference M. Garey, D. Johnson, F. Preparata and R, Tarjan, Triangulating a simple polygon, Inf. Process. Lett. 7, (1978). B. Chazelle. A theorem on polygon cutting with applications. In Proc. 23rd Annu. IEEE Sympos. Found. Comput. Sci., pages 339–349, 1982. R. Seidel. A simple and fast incremental randomized algorithm for computing trapezoidal decompositions and for triangulating polygons. Comput. Geom. Theory Appl., 1:51–64, 1991.  Reference 부분에서, 책에서 O(n) optimal 알고리즘의 존재여부를 말했었는데 (Chazelle [92, 94]), 그런게 있지만 대신 대신 드럽게 복잡하고 실행속도도 실용적으로 느려터졌다 정도 잠깐 언급하고 넘어가시면 좋을 것 같습니다. (스크립트 구술도 괜찮습니다)


Download ppt "Polygon Triangulation"

Similar presentations


Ads by Google