Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf ·...

113
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 1397-2 1 / 38

Transcript of Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf ·...

Page 1: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Polygon Triangulation

1397-2

1 / 38

Page 2: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Motivation:The Art Gallery Problem

2 / 38

Page 3: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Motivation:The Art Gallery Problem

2 / 38

Page 4: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Motivation:The Art Gallery Problem

2 / 38

Page 5: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

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

Simple Polygon Non-Simple Polygons3 / 38

Page 6: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

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

Convex Star-shaped

3 / 38

Page 7: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

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

3 / 38

Page 8: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

diagonals:Triangulation: A decomposition of a polygon intotriangles by a maximal set of non-intersectingdiagonals.

diagonals

not diagonal

4 / 38

Page 9: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

diagonals:Triangulation: A decomposition of a polygon intotriangles by a maximal set of non-intersectingdiagonals.

4 / 38

Page 10: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

diagonals:Triangulation: A decomposition of a polygon intotriangles by a maximal set of non-intersectingdiagonals.

4 / 38

Page 11: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

diagonals:Triangulation: A decomposition of a polygon intotriangles by a maximal set of non-intersectingdiagonals.

4 / 38

Page 12: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

Guarding after triangulation:

5 / 38

Page 13: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

Guarding after triangulation:

5 / 38

Page 14: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

Guarding after triangulation:

5 / 38

Page 15: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

Guarding after triangulation:

5 / 38

Page 16: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating PolygonsDefinitions

Guarding after triangulation:

5 / 38

Page 17: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

6 / 38

Page 18: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

6 / 38

Page 19: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

6 / 38

Page 20: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

vLeftmost vertex

6 / 38

Page 21: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

v

w

u

6 / 38

Page 22: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

Theorem 3.1Every simple polygon admits a triangulation, and anytriangulation of a simple polygon with n vertices consistsof exactly n− 2 triangles.

Proof. By induction.Base Case: n = 3 (Obvious)Case 1: Neighbors of v makea diagonal.Case 2: Otherwise.

v

w

u

v′

6 / 38

Page 23: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Guarding a triangulated polygon

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

7 / 38

Page 24: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Guarding a triangulated polygon

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

7 / 38

Page 25: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Guarding a triangulated polygon

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

7 / 38

Page 26: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Guarding a triangulated polygon

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

7 / 38

Page 27: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Guarding a triangulated polygon

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

7 / 38

Page 28: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 29: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 30: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 31: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 32: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 33: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 34: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 / 38

Page 35: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Art Gallery Theorem

Theorem 3.2 (Art Gallery Theorem)For a simple polygon with n vertices, bn/3c cameras areoccasionally necessary and always sufficient to haveevery point in the polygon visible from at least one of thecameras.

prongsbn/3c

10 / 38

Page 36: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Art Gallery Theorem

We will show:How to compute a triangulation in O(n log n) time.

Therefore:

Theorem 3.3Let P be a simple polygon with n vertices. A set of bn/3ccamera positions in P such that any point inside P isvisible from at least one of the cameras can be computedin O(n log n) time.

11 / 38

Page 37: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

How can we compute a triangulation of a given polygon?

12 / 38

Page 38: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 39: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 40: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 41: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 42: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 43: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulation algorithmsA really naive algorithm: check all

(n2

)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 untilChazelle produced an optimal O(n) algorithm in1991.Linear time algorithm insanely complicated; there arerandomized, expected linear time that are moreaccessible.Here we present a O(n log n) algorithm.

13 / 38

Page 44: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Algorithm Outline

Algorithm Outline1 Partition polygon into monotone polygons.2 Triangulate each monotone piece.

14 / 38

Page 45: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

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

15 / 38

Page 46: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis`

`′

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

15 / 38

Page 47: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis

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

15 / 38

Page 48: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis

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

15 / 38

Page 49: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis

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

15 / 38

Page 50: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis

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

15 / 38

Page 51: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

y−axis

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

15 / 38

Page 52: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone polygon

`-monotone polygonP is called monotone w. r. t. ` if ∀`′ perpendicular to ` theintersection of P with ` is connected (a line segment, apoint, or empty).

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

15 / 38

Page 53: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Partition P into monotone pieces

=merge vertex

=regular vertex

=end vertex

=start vertex

=split vertex

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14

v15

e1

e2

e3e4e5

e6

e7e8

e9

e10e11

e13

e14e15

e12

16 / 38

Page 54: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Partition P into monotone pieces

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

Proof. Assume P is not y-monotone. We show that it hasan split or merge vertex.

By Lemma 3.4, P has been partitioned into y-monotonepieces once we get rid of its split and merge vertices.

17 / 38

Page 55: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Partition P into monotone pieces

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

Proof. Assume P is not y-monotone. We show that it hasan split or merge vertex.

p q r

P

merge vertex

p = r q r

split vertex(a) (b)

P

P

By Lemma 3.4, P has been partitioned into y-monotonepieces once we get rid of its split and merge vertices.

17 / 38

Page 56: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Partition P into monotone pieces

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

Proof. Assume P is not y-monotone. We show that it hasan split or merge vertex.

p q r

P

merge vertex

p = r q r

split vertex(a) (b)

P

P

By Lemma 3.4, P has been partitioned into y-monotonepieces once we get rid of its split and merge vertices.

17 / 38

Page 57: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing split vertices:

A sweep line algorithm.Events: all the pointsGoal: To add diagonalsfrom each split vertex toa vertex lying above it.helper(ej): Lowestvertex above the sweepline s. t. the horizontalsegment connecting thevertex to ej lies inside P .Connect split vertices tothe helper of the edge totheir left.

18 / 38

Page 58: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing split vertices:

A sweep line algorithm.Events: all the pointsGoal: To add diagonalsfrom each split vertex toa vertex lying above it.helper(ej): Lowestvertex above the sweepline s. t. the horizontalsegment connecting thevertex to ej lies inside P .Connect split vertices tothe helper of the edge totheir left.

18 / 38

Page 59: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing split vertices:

A sweep line algorithm.Events: all the pointsGoal: To add diagonalsfrom each split vertex toa vertex lying above it.helper(ej): Lowestvertex above the sweepline s. t. the horizontalsegment connecting thevertex to ej lies inside P .Connect split vertices tothe helper of the edge totheir left.

18 / 38

Page 60: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing split vertices:

A sweep line algorithm.Events: all the pointsGoal: To add diagonalsfrom each split vertex toa vertex lying above it.helper(ej): Lowestvertex above the sweepline s. t. the horizontalsegment connecting thevertex to ej lies inside P .Connect split vertices tothe helper of the edge totheir left.

ej ekvi

ei−1 ei

helper(ej)

18 / 38

Page 61: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing split vertices:

A sweep line algorithm.Events: all the pointsGoal: To add diagonalsfrom each split vertex toa vertex lying above it.helper(ej): Lowestvertex above the sweepline s. t. the horizontalsegment connecting thevertex to ej lies inside P .Connect split vertices tothe helper of the edge totheir left.

ej ekvi

ei−1 ei

helper(ej)

18 / 38

Page 62: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing merge vertices:

Connect each merge vertex to the highest vertexbelow the sweep line in between ej and ek.But we do not know the point.When we reach a vertex vm that replaces the helperof ej , then this is the vertex we are looking for.

19 / 38

Page 63: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing merge vertices:

Connect each merge vertex to the highest vertexbelow the sweep line in between ej and ek.But we do not know the point.When we reach a vertex vm that replaces the helperof ej , then this is the vertex we are looking for.

19 / 38

Page 64: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Removing split/merge vertices:Removing merge vertices:

Connect each merge vertex to the highest vertexbelow the sweep line in between ej and ek.But we do not know the point.When we reach a vertex vm that replaces the helperof ej , then this is the vertex we are looking for.

ejvi ek

vm

diagonal will be addedwhen the sweep linereaches vm.

19 / 38

Page 65: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Data Structure:

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

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

2 Because we are only interested in edges to the left ofsplit and merge vertices we only need to store edgesin 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 / 38

Page 66: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Data Structure:

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

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

2 Because we are only interested in edges to the left ofsplit and merge vertices we only need to store edgesin 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 / 38

Page 67: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Data Structure:

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

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

2 Because we are only interested in edges to the left ofsplit and merge vertices we only need to store edgesin 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 / 38

Page 68: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Data Structure:

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

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

2 Because we are only interested in edges to the left ofsplit and merge vertices we only need to store edgesin 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 / 38

Page 69: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 pointshave the same y-coordinate, the one with smallerx-coordinate has higher priority.

2. Initialize an empty binary search tree T .3. while Q is not empty4. Remove the vertex vi with the highest priority

from Q.5. Call the appropriate procedure to handle the

vertex, depending on its type.

21 / 38

Page 70: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14v15

e1

e2

e3e4e5

e6

e7

e8

e9

e10e11

e13

e14

e15

e12

22 / 38

Page 71: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Make Monotone Algorithm:Algorithm HANDLEENDVERTEX(vi)1. if helper(ei−1) is a merge vertex2. then Insert the diagonal connecting vi to

helper(ei−1) in D.3. Delete ei−1 from T .

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14v15

e1

e2

e3e4e5

e6

e7

e8

e9

e10e11

e13

e14

e15

e12

23 / 38

Page 72: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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.

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14v15

e1

e2

e3e4e5

e6

e7

e8

e9

e10e11

e13

e14

e15

e12

24 / 38

Page 73: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Make Monotone Algorithm:Algorithm HANDLEMERGEVERTEX(vi)1. if helper(ei−1) is a merge vertex2. 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 vertex6. then Insert the diag. vi to helper(ej) in D.7. helper(ej)← vi.

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14v15

e1

e2

e3e4e5

e6

e7

e8

e9

e10e11

e13

e14

e15

e12

25 / 38

Page 74: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Make Monotone Algorithm:Algorithm HANDLEREGULARVERTEX(vi)1. if the interior of P lies to the right of vi2. then if helper(ei−1) is a merge vertex3. 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 vertex8. then Insert the diag. vi to helper(ej) in D.9. helper(ej)← vi

v1v2

v3v4

v5

v6

v7

v8

v9

v10

v11

v12

v13

v14v15

e1

e2

e3e4e5

e6

e7

e8

e9

e10e11

e13

e14

e15

e12

26 / 38

Page 75: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Lemma 3.5Algorithm MAKEMONOTONE adds a set ofnon-intersecting diagonals that partitions P intomonotone subpolygons.

Proof. (For split vertices) (other cases are similar)No vertex inside R.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 / 38

Page 76: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Lemma 3.5Algorithm MAKEMONOTONE adds a set ofnon-intersecting diagonals that partitions P intomonotone subpolygons.

Proof. (For split vertices) (other cases are similar)No vertex inside R.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 / 38

Page 77: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Lemma 3.5Algorithm MAKEMONOTONE adds a set ofnon-intersecting diagonals that partitions P intomonotone subpolygons.

Proof. (For split vertices) (other cases are similar)No vertex inside R.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 / 38

Page 78: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Lemma 3.5Algorithm MAKEMONOTONE adds a set ofnon-intersecting diagonals that partitions P intomonotone subpolygons.

Proof. (For split vertices) (other cases are similar)No vertex inside R.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 / 38

Page 79: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Lemma 3.5Algorithm MAKEMONOTONE adds a set ofnon-intersecting diagonals that partitions P intomonotone subpolygons.

Proof. (For split vertices) (other cases are similar)No vertex inside R.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 / 38

Page 80: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 81: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 82: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 83: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 84: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 85: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 86: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 87: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

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 one operation on Q: O(log n) time.2 at most one query on T : O(log n) time.3 one 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 clearlylinear: every vertex is stored at most once in Q, andevery edge is stored at most once in T .

28 / 38

Page 88: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Monotone Decomposition:

Theorem 3.6A simple polygon with n vertices can be partitioned intoy-monotone polygons in O(n log n) time with an algorithmthat uses O(n) storage.

29 / 38

Page 89: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

30 / 38

Page 90: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

Triangulation Algorithm:1 The algorithm handles the vertices in order of

decreasing y-coordinate. (Left to right for points withsame y-coordinate).

2 The algorithm requires a stack S as auxiliary datastructure. It keeps the points that handled but mightneed more diagonals.

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

4 Algorithm invariant: the part of P that still needs tobe triangulated, and lies above the last vertex thathas been encountered so far, looks like a funnelturned upside down.

31 / 38

Page 91: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

Triangulation Algorithm:1 The algorithm handles the vertices in order of

decreasing y-coordinate. (Left to right for points withsame y-coordinate).

2 The algorithm requires a stack S as auxiliary datastructure. It keeps the points that handled but mightneed more diagonals.

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

4 Algorithm invariant: the part of P that still needs tobe triangulated, and lies above the last vertex thathas been encountered so far, looks like a funnelturned upside down.

31 / 38

Page 92: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

Triangulation Algorithm:1 The algorithm handles the vertices in order of

decreasing y-coordinate. (Left to right for points withsame y-coordinate).

2 The algorithm requires a stack S as auxiliary datastructure. It keeps the points that handled but mightneed more diagonals.

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

4 Algorithm invariant: the part of P that still needs tobe triangulated, and lies above the last vertex thathas been encountered so far, looks like a funnelturned upside down.

31 / 38

Page 93: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

Triangulation Algorithm:1 The algorithm handles the vertices in order of

decreasing y-coordinate. (Left to right for points withsame y-coordinate).

2 The algorithm requires a stack S as auxiliary datastructure. It keeps the points that handled but mightneed more diagonals.

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

4 Algorithm invariant: the part of P that still needs tobe triangulated, and lies above the last vertex thathas been encountered so far, looks like a funnelturned upside down.

31 / 38

Page 94: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone Polygon

trianglessplit off

not yettriangulated

32 / 38

Page 95: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

33 / 38

Page 96: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

vj

e

top of stack

33 / 38

Page 97: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

vj

popped

e

33 / 38

Page 98: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

vj

popped

e

33 / 38

Page 99: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

popped

e

vj

33 / 38

Page 100: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 1: vj and top of stack on different chains

vj

popped

pushed

e

pushed

33 / 38

Page 101: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

vj

34 / 38

Page 102: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

vj

popped

34 / 38

Page 103: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

vj

popped

34 / 38

Page 104: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

vj

popped

popped

34 / 38

Page 105: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

vj

popped

popped

34 / 38

Page 106: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

pushed

vj

popped

popped andpushed

34 / 38

Page 107: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonCase 2: vj and top of stack on same chain

pushed

vj

popped andpushed

34 / 38

Page 108: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonAlgorithm TRIANGULATEMONOTONEPOLYGON(P )1. Merge the vertices on the left &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− 14. if uj and the vertex on top of S are on different chains5. 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 . Insertthese diagonals into D. Push the last vertex thathas 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.

Time Complexity: Step 1: O(n), Step 2: O(1).Steps 3-10: O(n)

35 / 38

Page 109: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Triangulating a Monotone PolygonAlgorithm TRIANGULATEMONOTONEPOLYGON(P )1. Merge the vertices on the left &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− 14. if uj and the vertex on top of S are on different chains5. 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 . Insertthese diagonals into D. Push the last vertex thathas 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.

Time Complexity: Step 1: O(n), Step 2: O(1).Steps 3-10: O(n)

35 / 38

Page 110: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Polygon Triangulation

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

36 / 38

Page 111: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Generalizing to any planar subdivision

Theorem 3.9A planar subdivision with n vertices in total can betriangulated in O(n log n) time with an algorithm that usesO(n) storage.

37 / 38

Page 112: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

Generalizing to any planar subdivision

Theorem 3.9A planar subdivision with n vertices in total can betriangulated in O(n log n) time with an algorithm that usesO(n) storage.

37 / 38

Page 113: Polygon Triangulation - yazd.ac.ircs.yazd.ac.ir/farshi/Teaching/CG3972/Slides/Triang.pdf · Partitioning a Polygon into Monotone Pieces Triangulating a Monotone Polygon Guarding a

Yazd Univ.

ComputationalGeometry

The Art GalleryProblemGuarding andTriangulations

ComputingtriangulationPartitioning a Polygon intoMonotone Pieces

Triangulating a MonotonePolygon

END.

38 / 38