0% found this document useful (0 votes)
39 views

Geometric Algorithms: Triangulating A Polygon

The document discusses algorithms for triangulating polygons. It begins by introducing the art gallery problem of determining the minimum number of cameras needed to monitor an art gallery. The art gallery theorem states that n/3 cameras are always sufficient to monitor a polygon with n vertices. The document then covers how any polygon can be triangulated by adding diagonals, and how this triangulation allows coloring the vertices with 3 colors. It also discusses using plane sweep to partition polygons into monotone pieces that can each be triangulated efficiently.

Uploaded by

nikhilm_21
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Geometric Algorithms: Triangulating A Polygon

The document discusses algorithms for triangulating polygons. It begins by introducing the art gallery problem of determining the minimum number of cameras needed to monitor an art gallery. The art gallery theorem states that n/3 cameras are always sufficient to monitor a polygon with n vertices. The document then covers how any polygon can be triangulated by adding diagonals, and how this triangulation allows coloring the vertices with 3 colors. It also discusses using plane sweep to partition polygons into monotone pieces that can each be triangulated efficiently.

Uploaded by

nikhilm_21
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Motivation Triangulating a polygon

Triangulating a polygon

Geometric Algorithms
Lecture 2: Triangulating a polygon

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

Polygons and visibility

Two points in a simple polygon can see each other if their connecting line segment is in the polygon

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

Art gallery problem

Art Galley Problem: How many cameras are needed to guard a given art gallery so that every point is seen?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

Art gallery problem


In geometry terminology: How many points are needed in a simple polygon with n vertices so that every point in the polygon is seen? The optimization problem is computationally dicult Art Galley Theorem: n/3 cameras are occasionally necessary but always sucient

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

Triangulation, diagonal

Why are n/3 always enough? Assume polygon P is triangulated: a decomposition of P into disjoint triangles by a maximal set of non-intersecting diagonals Diagonal of P : open line segment that connects two vertices of P and fully lies in the interior of P

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

A triangulation always exists


Lemma: A simple polygon with n vertices can always be triangulated, and always have n 2 triangles Proof: Induction on n. If n = 3, it is trivial Assume n > 3. Consider the leftmost vertex v and its two neighbors u and w. Either uw is a diagonal (case 1), or part of the boundary of P is in uvw (case 2) Choose the vertex t in uvw farthest from the line through u and w, then vt must be a diagonal
Geometric Algorithms

u v w u v w

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

A triangulation always exists

In case 1, uw cuts the polygon into a triangle and a simple polygon with n 1 vertices, and we apply induction In case 2, vt cuts the polygon into two simple polygons with m and n m + 2 vertices 3 m n 1, and we also apply induction By induction, the two polygons can be triangulated using m 2 and n m + 2 2 = n m triangles. So the original polygon is triangulated using m 2 + n m = n 2 triangles

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

A 3-coloring always exists


Observe: the dual of a triangulated simple polygon is a tree Lemma: The vertices of a triangulated simple polygon can always be 3-colored Proof: Induction. True for a triangle Every tree has a leaf. Remove the corresponding triangle from the triangulated polygon, color its vertices, add the triangle back, and let the extra vertex have the color dierent from its neighbors

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

A 3-coloring always exists

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

n/3 cameras are enough

For a 3-colored, triangulated simple polygon, one of the color classes is used by at most n/3 colors. Place the cameras at these vertices This argument is called the pigeon-hole principle

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Visibility in polygons Triangulation Proof of the Art gallery theorem

n/3 cameras are enough

Question: Why does the proof fail when the polygon has holes?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Two-ears for triangulation

Using the two-ears theorem: (an ear consists of three consecutive vertices u, v, w where uw is a diagonal) Find an ear, cut it o with a diagonal, triangulate the rest iteratively Question: Why does every simple polygon have an ear? Question: How ecient is this algorithm?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Overview

A simple polygon is y-monotone i any horizontal line intersects it in a connected set (or not at all) Use plane sweep to partition the polygon into y monotone polygons Then triangulate each y-monotone polygon

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Monotone polygons

A y-monotone polygon has a top vertex, a bottom vertex, and two y-monotone chains between top and bottom as its boundary Any simple polygon with one top vertex and one bottom vertex is y-monotone

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Vertex types
What types of vertices does a general simple polygon have? start stop split merge regular . . . imagining a sweep line going top to bottom

start merge regular split end

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Find diagonals from each merge vertex down, and from each split vertex up A simple polygon with no split or merge vertices can have at most one start and one stop vertex, so it is y-monotone

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Find diagonals from each merge vertex down, and from each split vertex up A simple polygon with no split or merge vertices can have at most one start and one stop vertex, so it is y-monotone

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas
explored explored

unexplored
Geometric Algorithms

unexplored
Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the upper endpoint of the edge immediately left of the merge vertex?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the upper endpoint of the edge immediately left of the merge vertex?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the upper endpoint of the edge immediately left of the merge vertex?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the last vertex passed in the same component?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the last vertex passed in the same component?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Sweep ideas

Where can a diagonal from a split vertex go? Perhaps the last vertex passed in the same component?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Status of sweep

The status is the set of edges intersecting the sweep line that have the polygon to their right, sorted from left to right, and each with their helper: the last vertex passed in that component

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Helpers of edges

The helper for an edge e that has the polygon right of it, and a position of the sweep line, is the lowest vertex v above the sweep line such that the horizontal line segment connecting e and v is inside the polygon

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Status structure, event list

The status structure stores all edges that have the polygon to the right, with their helper, sorted from left to right in the leaves of a balanced binary search tree The events happen only at the vertices: sort them by y-coordinate and put them in a list (or array, or tree)

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Main algorithm

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Event handling

Start vertex v: Insert the counterclockwise incident edge in T with v as the helper

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Event handling

End vertex v: Delete the clockwise incident edge and its helper from T

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Event handling

Regular vertex v: If the polygon is right of the two incident edges, then replace the upper edge by the lower edge in T , and make v the helper If the polygon is left of the two incident edges, then nd the edge e directly left of v, and replace its helper by v

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Event handling

Merge vertex v: Remove the edge clockwise from v from T Find the edge e directly left of v, and replace its helper by v

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Event handling

Split vertex v: Find the edge e directly left of v, and choose as a diagonal the edge between its helper and v Replace the helper of e by v Insert the edge counterclockwise from v in T , with v as its helper

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Eciency

Sorting all events by y-coordinate takes O(n log n) time Every event takes O(log n) time, because it only involves querying, inserting and deleting in T

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Degenerate cases

Question: Which degenerate cases arise in this algorithm?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Representation

A simple polygon with some diagonals is a subdivision use a DCEL Question: How many diagonals may be chosen to the same vertex?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

More sweeping

With an upward sweep in each subpolygon, we can nd a diagonal down from every merge vertex (which is a split vertex for an upward sweep!) This makes all subpolygons y-monotone

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Result

Theorem: A simple polygon with n vertices can be partitioned into y-monotone pieces in O(n log n) time

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Triangulating a monotone polygon

How to triangulate a y-monotone polygon?

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

The algorithm

Sort the vertices top-to-bottom by a merge of the two chains Initialize a stack. Pop the rst two vertices Take the next vertex v, and triangulate as much as possible, top-down, while popping the stack Push v onto the stack

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Result

Theorem: A simple polygon with n vertices can be partitioned into y-monotone pieces in O(n log n) time Theorem: A monotone polygon with n vertices can be triangulated O(n) time Can we immediately conclude: A simple polygon with n vertices can be triangulated O(n log n) time ???

Geometric Algorithms

Lecture 2: Triangulating a polygon

Motivation Triangulating a polygon

Towards an ecient algorithm Partitioning into monotone pieces Triangulating a monotone polygon Triangulating a simple polygon

Result
We need to argue that all monotone polygons together that we will triangulate have O(n) vertices Initially we had n edges. We add at most n 3 diagonals in the sweeps. So all monotone polygons together have at most 2n 3 edges, and therefore at most 2n 3 vertices Hence we can conclude that triangulating all monotone polygons together takes only O(n) time Theorem: A simple polygon with n vertices can be triangulated O(n log n) time

Geometric Algorithms

Lecture 2: Triangulating a polygon

You might also like