Polygon Triangulation Computational Geometry The Art Gallery - - PowerPoint PPT Presentation

polygon triangulation
SMART_READER_LITE
LIVE PREVIEW

Polygon Triangulation Computational Geometry The Art Gallery - - PowerPoint PPT Presentation

Yazd Univ. Polygon Triangulation Computational Geometry The Art Gallery Problem Guarding and Triangulations Computing triangulation 1392-1 Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon 1 / 37


slide-1
SLIDE 1

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Polygon Triangulation

1392-1

1 / 37

slide-2
SLIDE 2

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Motivation:

The Art Gallery Problem

2 / 37

slide-3
SLIDE 3

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Motivation:

The Art Gallery Problem

2 / 37

slide-4
SLIDE 4

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Motivation:

The Art Gallery Problem

2 / 37

slide-5
SLIDE 5

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Simple polygon: Regions enclosed by a single closed polygonal chain that does not intersect itself. Question: How many cameras do we need to guard a simple polygon? Answer: Depends on the polygon. One solution: Decompose the polygon to parts which are simple to guard.

Simple Polygon Non-Simple Polygons

3 / 37

slide-6
SLIDE 6

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Simple polygon: Regions enclosed by a single closed polygonal chain that does not intersect itself. Question: How many cameras do we need to guard a simple polygon? Answer: Depends on the polygon. One solution: Decompose the polygon to parts which are simple to guard.

Convex Star-shaped

3 / 37

slide-7
SLIDE 7

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Simple polygon: Regions enclosed by a single closed polygonal chain that does not intersect itself. Question: How many cameras do we need to guard a simple polygon? Answer: Depends on the polygon. One solution: Decompose the polygon to parts which are simple to guard.

3 / 37

slide-8
SLIDE 8

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

diagonals: Triangulation: A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals. diagonals not diagonal

4 / 37

slide-9
SLIDE 9

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

diagonals: Triangulation: A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals.

4 / 37

slide-10
SLIDE 10

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

diagonals: Triangulation: A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals.

4 / 37

slide-11
SLIDE 11

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

diagonals: Triangulation: A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals.

4 / 37

slide-12
SLIDE 12

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Guarding after triangulation:

5 / 37

slide-13
SLIDE 13

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Guarding after triangulation:

5 / 37

slide-14
SLIDE 14

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Guarding after triangulation:

5 / 37

slide-15
SLIDE 15

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Guarding after triangulation:

5 / 37

slide-16
SLIDE 16

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating Polygons

Definitions

Guarding after triangulation:

5 / 37

slide-17
SLIDE 17

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Questions:

Does a triangulation always exist? How many triangles can there be in a triangulation?

Theorem 3.1

Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists

  • f exactly n − 2 triangles.
  • Proof. By induction.

6 / 37

slide-18
SLIDE 18

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Questions:

Does a triangulation always exist? How many triangles can there be in a triangulation?

Theorem 3.1

Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists

  • f exactly n − 2 triangles.
  • Proof. By induction.

6 / 37

slide-19
SLIDE 19

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Questions:

Does a triangulation always exist? How many triangles can there be in a triangulation?

Theorem 3.1

Every simple polygon admits a triangulation, and any triangulation of a simple polygon with n vertices consists

  • f exactly n − 2 triangles.
  • Proof. By induction.

v w u v w u v′

6 / 37

slide-20
SLIDE 20

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Guarding a triangulated polygon

TP : A triangulation of a simple polygon P. Select S ⊆ the vertices of P, such that any triangle in TP has at least one vertex in S, and place the cameras at vertices in S. To find such a subset: find a 3-coloring of a triangulated polygon. In a 3-coloring of TP , every triangle has a blue, a red, and a black vertex. Hence, if we place cameras at all red vertices, we have guarded the whole polygon. By choosing the smallest color class to place the cameras, we can guard P using at most ⌊n/3⌋ cameras.

7 / 37

slide-21
SLIDE 21

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Guarding a triangulated polygon

TP : A triangulation of a simple polygon P. Select S ⊆ the vertices of P, such that any triangle in TP has at least one vertex in S, and place the cameras at vertices in S. To find such a subset: find a 3-coloring of a triangulated polygon. In a 3-coloring of TP , every triangle has a blue, a red, and a black vertex. Hence, if we place cameras at all red vertices, we have guarded the whole polygon. By choosing the smallest color class to place the cameras, we can guard P using at most ⌊n/3⌋ cameras.

7 / 37

slide-22
SLIDE 22

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Guarding a triangulated polygon

TP : A triangulation of a simple polygon P. Select S ⊆ the vertices of P, such that any triangle in TP has at least one vertex in S, and place the cameras at vertices in S. To find such a subset: find a 3-coloring of a triangulated polygon. In a 3-coloring of TP , every triangle has a blue, a red, and a black vertex. Hence, if we place cameras at all red vertices, we have guarded the whole polygon. By choosing the smallest color class to place the cameras, we can guard P using at most ⌊n/3⌋ cameras.

7 / 37

slide-23
SLIDE 23

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Guarding a triangulated polygon

TP : A triangulation of a simple polygon P. Select S ⊆ the vertices of P, such that any triangle in TP has at least one vertex in S, and place the cameras at vertices in S. To find such a subset: find a 3-coloring of a triangulated polygon. In a 3-coloring of TP , every triangle has a blue, a red, and a black vertex. Hence, if we place cameras at all red vertices, we have guarded the whole polygon. By choosing the smallest color class to place the cameras, we can guard P using at most ⌊n/3⌋ cameras.

7 / 37

slide-24
SLIDE 24

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Guarding a triangulated polygon

TP : A triangulation of a simple polygon P. Select S ⊆ the vertices of P, such that any triangle in TP has at least one vertex in S, and place the cameras at vertices in S. To find such a subset: find a 3-coloring of a triangulated polygon. In a 3-coloring of TP , every triangle has a blue, a red, and a black vertex. Hence, if we place cameras at all red vertices, we have guarded the whole polygon. By choosing the smallest color class to place the cameras, we can guard P using at most ⌊n/3⌋ cameras.

7 / 37

slide-25
SLIDE 25

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Does a 3-coloring always exist?

Dual graph:

This graph G(TP ) has a node for every triangle in TP . There is an arc between two nodes ν and µ if t(ν) and t(µ) share a diagonal. G(TP ) is a tree.

?

µ ν

8 / 37

slide-26
SLIDE 26

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Does a 3-coloring always exist?

For 3-coloring:

Traverse the dual graph (DFS). Invariant: so far everything is nice. Start from any node of G(TP ); color the vertices. When we reach a node ν in G, coming from node µ. Only one vertex of t(ν) remains to be colored.

?

µ ν

9 / 37

slide-27
SLIDE 27

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Art Gallery Theorem

Theorem 3.2 (Art Gallery Theorem)

For a simple polygon with n vertices, ⌊n/3⌋ cameras are

  • ccasionally necessary and always sufficient to have

every point in the polygon visible from at least one of the cameras.

prongs

⌊n/3⌋

10 / 37

slide-28
SLIDE 28

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Art Gallery Theorem

We will show:

How to compute a triangulation in O(n log n) time. Therefore:

Theorem 3.3

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 log n) time.

11 / 37

slide-29
SLIDE 29

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

How can we compute a triangulation of a given polygon?

12 / 37

slide-30
SLIDE 30

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulation algorithms

A really naive algorithm: check all n

2

  • choices for a

diagonal, each takes O(n) time. Time complexity: O(n3). A better naive algorithm: find an ear in O(n) time, then recurse. Total time: O(n2). First non-trivial algorithm: O(n log n) (1978). A long series of papers and algorithms in 80s until Chazelle produced an optimal O(n) algorithm in 1991. Linear time algorithm insanely complicated; there are randomized, expected linear time that are more accessible. Here we present a O(n log n) algorithm.

13 / 37

slide-31
SLIDE 31

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Algorithm Outline

Algorithm Outline

1

Partition polygon into monotone polygons.

2

Triangulate each monotone piece.

14 / 37

slide-32
SLIDE 32

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

Definition:

A point p is below another point q if py < qy or py = qy and px > qx. p is above q if py > qy or py = qy and px < qx.

15 / 37

slide-33
SLIDE 33

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

ℓ ℓ′

15 / 37

slide-34
SLIDE 34

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

15 / 37

slide-35
SLIDE 35

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

15 / 37

slide-36
SLIDE 36

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

15 / 37

slide-37
SLIDE 37

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

15 / 37

slide-38
SLIDE 38

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

y−axis

15 / 37

slide-39
SLIDE 39

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone polygon

ℓ-monotone polygon

P is called monotone w. r. t. ℓ if ∀ℓ′ perpendicular to ℓ the intersection of P with ℓ is connected (a line segment, a point, or empty).

Definition:

A point p is below another point q if py < qy or py = qy and px > qx. p is above q if py > qy or py = qy and px < qx.

15 / 37

slide-40
SLIDE 40

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Partition P into monotone pieces

=merge vertex =regular vertex =end vertex =start vertex =split vertex v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

16 / 37

slide-41
SLIDE 41

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Partition P into monotone pieces

Lemma 3.4

If P has no split or merge vertices then it is y-monotone.

  • Proof. Assume P is not y-monotone.

P has been partitioned into y-monotone pieces once we get rid of its split and merge vertices.

17 / 37

slide-42
SLIDE 42

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Partition P into monotone pieces

Lemma 3.4

If P has no split or merge vertices then it is y-monotone.

  • Proof. Assume P is not y-monotone.

p q r P merge vertex p = r q r split vertex (a) (b) P P

P has been partitioned into y-monotone pieces once we get rid of its split and merge vertices.

17 / 37

slide-43
SLIDE 43

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Partition P into monotone pieces

Lemma 3.4

If P has no split or merge vertices then it is y-monotone.

  • Proof. Assume P is not y-monotone.

p q r P merge vertex p = r q r split vertex (a) (b) P P

P has been partitioned into y-monotone pieces once we get rid of its split and merge vertices.

17 / 37

slide-44
SLIDE 44

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing split vertices:

A sweep line algorithm. Events: all the points Goal: To add diagonals from each split vertex to a vertex lying above it. helper(ej): Lowest vertex above the sweep line s. t. the horizontal segment connecting the vertex to ej lies inside P. Connect split vertices to the helper of the edge to their left.

18 / 37

slide-45
SLIDE 45

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing split vertices:

A sweep line algorithm. Events: all the points Goal: To add diagonals from each split vertex to a vertex lying above it. helper(ej): Lowest vertex above the sweep line s. t. the horizontal segment connecting the vertex to ej lies inside P. Connect split vertices to the helper of the edge to their left.

18 / 37

slide-46
SLIDE 46

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing split vertices:

A sweep line algorithm. Events: all the points Goal: To add diagonals from each split vertex to a vertex lying above it. helper(ej): Lowest vertex above the sweep line s. t. the horizontal segment connecting the vertex to ej lies inside P. Connect split vertices to the helper of the edge to their left.

ej ek vi ei−1 ei helper(ej)

18 / 37

slide-47
SLIDE 47

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing split vertices:

A sweep line algorithm. Events: all the points Goal: To add diagonals from each split vertex to a vertex lying above it. helper(ej): Lowest vertex above the sweep line s. t. the horizontal segment connecting the vertex to ej lies inside P. Connect split vertices to the helper of the edge to their left.

ej ek vi ei−1 ei helper(ej)

18 / 37

slide-48
SLIDE 48

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing merge vertices:

Connect each merge vertex to the highest vertex below the sweep line in between ej and ek. But we do not know the point. When we reach a vertex vm that replaces the helper

  • f ej, then this is the vertex we are looking for.

19 / 37

slide-49
SLIDE 49

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing merge vertices:

Connect each merge vertex to the highest vertex below the sweep line in between ej and ek. But we do not know the point. When we reach a vertex vm that replaces the helper

  • f ej, then this is the vertex we are looking for.

19 / 37

slide-50
SLIDE 50

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Removing split/merge vertices:

Removing merge vertices:

Connect each merge vertex to the highest vertex below the sweep line in between ej and ek. But we do not know the point. When we reach a vertex vm that replaces the helper

  • f ej, then this is the vertex we are looking for.

ej vi ek vm

diagonal will be added when the sweep line reaches vm.

19 / 37

slide-51
SLIDE 51

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Data Structure:

For this approach, we need to find the edge to the left of each vertex. To do that:

1

We store the edges of P intersecting the sweep line in the leaves of a dynamic binary search tree T .

2

Because we are only interested in edges to the left of split and merge vertices we only need to store edges in T that have the interior of P to their right.

3

With each edge in T we store its helper.

4

We store P in DCEL form and make changes such that it remains valid.

20 / 37

slide-52
SLIDE 52

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Data Structure:

For this approach, we need to find the edge to the left of each vertex. To do that:

1

We store the edges of P intersecting the sweep line in the leaves of a dynamic binary search tree T .

2

Because we are only interested in edges to the left of split and merge vertices we only need to store edges in T that have the interior of P to their right.

3

With each edge in T we store its helper.

4

We store P in DCEL form and make changes such that it remains valid.

20 / 37

slide-53
SLIDE 53

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Data Structure:

For this approach, we need to find the edge to the left of each vertex. To do that:

1

We store the edges of P intersecting the sweep line in the leaves of a dynamic binary search tree T .

2

Because we are only interested in edges to the left of split and merge vertices we only need to store edges in T that have the interior of P to their right.

3

With each edge in T we store its helper.

4

We store P in DCEL form and make changes such that it remains valid.

20 / 37

slide-54
SLIDE 54

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Data Structure:

For this approach, we need to find the edge to the left of each vertex. To do that:

1

We store the edges of P intersecting the sweep line in the leaves of a dynamic binary search tree T .

2

Because we are only interested in edges to the left of split and merge vertices we only need to store edges in T that have the interior of P to their right.

3

With each edge in T we store its helper.

4

We store P in DCEL form and make changes such that it remains valid.

20 / 37

slide-55
SLIDE 55

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm MAKEMONOTONE(P ) Input: A simple polygon P stored in a DCEL 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-coordinate, the one with smaller x-coordinate has higher priority. 2. Initialize an empty binary search tree T . 3. while Q is not empty 4. Remove the vertex vi with the highest priority from Q. 5. Call the appropriate procedure to handle the vertex, depending on its type.

21 / 37

slide-56
SLIDE 56

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm HANDLESTARTVERTEX(vi) 1. Insert ei in T and set helper(ei) to vi.

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

22 / 37

slide-57
SLIDE 57

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm HANDLEENDVERTEX(vi) 1. if helper(ei−1) is a merge vertex 2. then Insert the diagonal connecting vi to helper(ei−1) in D. 3. Delete ei−1 from T .

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

23 / 37

slide-58
SLIDE 58

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm HANDLESPLITVERTEX(vi) 1. Search in T to find the edge ej directly left of vi. 2. Insert the diagonal connecting vi to helper(ej) in D. 3. helper(ej) ← vi. 4. Insert ei in T and set helper(ei) to vi.

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

24 / 37

slide-59
SLIDE 59

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm HANDLEMERGEVERTEX(vi) 1. if helper(ei−1) is a merge vertex 2. then Insert the diag. vi to helper(ei−1) in D. 3. Delete ei−1 from T . 4. Search in T to find ej directly left of vi. 5. if helper(ej) is a merge vertex 6. then Insert the diag. vi to helper(ej) in D. 7. helper(ej) ← vi. v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

25 / 37

slide-60
SLIDE 60

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Make Monotone Algorithm:

Algorithm 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 the diag. 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 ej directly left of vi. 7. if helper(ej) is a merge vertex 8. then Insert the diag. vi to helper(ej) in D. 9. helper(ej) ← vi

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e13 e14 e15 e12

26 / 37

slide-61
SLIDE 61

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Lemma 3.5

Algorithm MAKEMONOTONE adds a set of non-intersecting diagonals that partitions P into monotone subpolygons.

  • Proof. (For split vertices) (other cases are similar)

No intersection between vivm and edges of P. No intersection between vivm and previous diag. R is empty, endpoints of previously added edges: above vi.

ej vm vi R ek

27 / 37

slide-62
SLIDE 62

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Lemma 3.5

Algorithm MAKEMONOTONE adds a set of non-intersecting diagonals that partitions P into monotone subpolygons.

  • Proof. (For split vertices) (other cases are similar)

No intersection between vivm and edges of P. No intersection between vivm and previous diag. R is empty, endpoints of previously added edges: above vi.

ej vm vi R ek

27 / 37

slide-63
SLIDE 63

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Lemma 3.5

Algorithm MAKEMONOTONE adds a set of non-intersecting diagonals that partitions P into monotone subpolygons.

  • Proof. (For split vertices) (other cases are similar)

No intersection between vivm and edges of P. No intersection between vivm and previous diag. R is empty, endpoints of previously added edges: above vi.

ej vm vi R ek

27 / 37

slide-64
SLIDE 64

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Lemma 3.5

Algorithm MAKEMONOTONE adds a set of non-intersecting diagonals that partitions P into monotone subpolygons.

  • Proof. (For split vertices) (other cases are similar)

No intersection between vivm and edges of P. No intersection between vivm and previous diag. R is empty, endpoints of previously added edges: above vi.

ej vm vi R ek

27 / 37

slide-65
SLIDE 65

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Running time/ Space complexity

Running time:

Constructing the priority queue Q: O(n) time. Initializing T : O(1) time. To handle an event, we perform:

1

  • ne operation on Q: O(log n) time.

2

at most one query on T : O(log n) time.

3

  • ne insertion, and one deletion on T : O(log n) time.

4

we insert at most two diagonals into D: O(1) time.

Space Complexity:

The amount of storage used by the algorithm is clearly linear: every vertex is stored at most once in Q, and every edge is stored at most once in T .

28 / 37

slide-66
SLIDE 66

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Running time/ Space complexity

Running time:

Constructing the priority queue Q: O(n) time. Initializing T : O(1) time. To handle an event, we perform:

1

  • ne operation on Q: O(log n) time.

2

at most one query on T : O(log n) time.

3

  • ne insertion, and one deletion on T : O(log n) time.

4

we insert at most two diagonals into D: O(1) time.

Space Complexity:

The amount of storage used by the algorithm is clearly linear: every vertex is stored at most once in Q, and every edge is stored at most once in T .

28 / 37

slide-67
SLIDE 67

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Monotone Decomposition:

Theorem 3.6

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.

29 / 37

slide-68
SLIDE 68

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

30 / 37

slide-69
SLIDE 69

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Triangulation Algorithm:

1

The algorithm handles the vertices in order of decreasing y-coordinate. (Left to right for points with same y-coordinate).

2

The algorithm requires a stack S as auxiliary data

  • structure. It keeps the points that handled but might

need more diagonals.

3

When we handle a vertex we add as many diagonals from this vertex to vertices on the stack as possible.

4

Algorithm invariant: the part of P that still needs to be triangulated, and lies above the last vertex that has been encountered so far, looks like a funnel turned upside down.

31 / 37

slide-70
SLIDE 70

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Triangulation Algorithm:

1

The algorithm handles the vertices in order of decreasing y-coordinate. (Left to right for points with same y-coordinate).

2

The algorithm requires a stack S as auxiliary data

  • structure. It keeps the points that handled but might

need more diagonals.

3

When we handle a vertex we add as many diagonals from this vertex to vertices on the stack as possible.

4

Algorithm invariant: the part of P that still needs to be triangulated, and lies above the last vertex that has been encountered so far, looks like a funnel turned upside down.

31 / 37

slide-71
SLIDE 71

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Triangulation Algorithm:

1

The algorithm handles the vertices in order of decreasing y-coordinate. (Left to right for points with same y-coordinate).

2

The algorithm requires a stack S as auxiliary data

  • structure. It keeps the points that handled but might

need more diagonals.

3

When we handle a vertex we add as many diagonals from this vertex to vertices on the stack as possible.

4

Algorithm invariant: the part of P that still needs to be triangulated, and lies above the last vertex that has been encountered so far, looks like a funnel turned upside down.

31 / 37

slide-72
SLIDE 72

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Triangulation Algorithm:

1

The algorithm handles the vertices in order of decreasing y-coordinate. (Left to right for points with same y-coordinate).

2

The algorithm requires a stack S as auxiliary data

  • structure. It keeps the points that handled but might

need more diagonals.

3

When we handle a vertex we add as many diagonals from this vertex to vertices on the stack as possible.

4

Algorithm invariant: the part of P that still needs to be triangulated, and lies above the last vertex that has been encountered so far, looks like a funnel turned upside down.

31 / 37

slide-73
SLIDE 73

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

triangles split off not yet triangulated

32 / 37

slide-74
SLIDE 74

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

33 / 37

slide-75
SLIDE 75

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

vj e top of stack

33 / 37

slide-76
SLIDE 76

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

vj popped e

33 / 37

slide-77
SLIDE 77

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

vj popped e

33 / 37

slide-78
SLIDE 78

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

popped e vj

33 / 37

slide-79
SLIDE 79

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 1: vj and top of stack on different chains

vj popped pushed e

pushed

33 / 37

slide-80
SLIDE 80

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

vj

34 / 37

slide-81
SLIDE 81

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

vj popped

34 / 37

slide-82
SLIDE 82

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

vj popped

34 / 37

slide-83
SLIDE 83

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

vj popped

popped

34 / 37

slide-84
SLIDE 84

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

vj popped

popped

34 / 37

slide-85
SLIDE 85

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

pushed vj popped

popped and pushed

34 / 37

slide-86
SLIDE 86

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Case 2: vj and top of stack on same chain

pushed vj

popped and pushed

34 / 37

slide-87
SLIDE 87

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Triangulating a Monotone Polygon

Algorithm TRIANGULATEMONOTONEPOLYGON(P) Input: A strictly y-monotone polygon P stored in D. Output: A triangulation of P stored in D. 1. Merge the vertices on the left chain and the vertices on the right chain of P into one sequence, sorted on decreasing y-coordinate. Let u1, . . . , un denote the sorted sequence. 2. Initialize an empty stack S, and push u1 and u2 onto it. 3. for j ← 3 to n − 1 4. if uj and the vertex on top of S are on different chains 5. then Pop all vertices from S. 6. Insert into D a diagonal from uj to each popped vertex, except the last one. 7. Push uj−1 and uj onto S. 8. else Pop one vertex from S. 9. Pop the other vertices from S as long as the diagonals from uj to them are inside P . Insert these diagonals into D. Push the last vertex that has been popped back onto S. 10. Push uj onto S.

  • 11. Add diagonals from un to all stack vertices except the first and

the last one.

35 / 37

slide-88
SLIDE 88

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Polygon Triangulation

Theorem 3.8

A simple polygon with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage.

Theorem 3.9

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.

36 / 37

slide-89
SLIDE 89

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

Polygon Triangulation

Theorem 3.8

A simple polygon with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage.

Theorem 3.9

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.

36 / 37

slide-90
SLIDE 90

Yazd Univ. Computational Geometry The Art Gallery Problem

Guarding and Triangulations

Computing triangulation

Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon

END.

37 / 37