- 215 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'POLYGON TRIANGULATION' - clover

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### POLYGON TRIANGULATION

THE ART GALERY PROBLEM

SİNEM GETİR

2008-2009

COMPUTER GRAPHIC SEMINAR

FEBRUARY 4, 2009

CONTENTS

- Guarding and triangulations
- Can we do better?
- 3-Coloring
- The art galery theorem
- Partitioning a polygon into monotone pieces
- Triangulating a Monotone polygon

The Art Gallery Problem

camera

How many cameras are needed to guard a gallery and

How should they be placed?

Transform to a Geometric Problem

- Floor plan may be sufficient and can be approximated as a simple polygon.
- A simple polygon is a region enclosed by single closed polygonal chain that doesn’t self-intersect
- A camera’s position corresponds to a point in the polygon
- A camera sees those points in the polygon to which it can be connected with an open segment that lies in the interior of the polygon
- assuming we have omni-cam that sees all directions

Guards have a viewport of 360°

- A polygon is completely guarded, if every point within the polygon is guarded by at least one of the watchmen

Simple Polygon Model

Model the art gallery as a region bounded by some simple

polygon (no self-crossing).

Regions with holes are not allowed.

convex polygon

one camera

an arbitrary n-gon (n vertices)

Bad news: finding the minimum number of cameras for a

given polygon is NP-hard (exponential time).

Triangulation

- Let P a simple polygon with n vertices
- We first decompose P into pieces that are easy to guard, namely triangles.
- DEFİNİTİON:A decomposition of a polygon into triangles by a maximal set of non-intersecting diagonals is called a triangulation of the polygon.
- Triangulations are usually NOT unique
- Many applications: visibility, robotics, mesh generation, point location etc.

Triangulation

To make things easier, we decompose a polygon into pieces that are

easy to guard.

Guard the polygon

by placing a camera in

every triangle …

Draw diagonals between pair of vertices.

an open line segment that connects two

vertices and lie in the interior of the polygon.

v

u

THE QUESTION…

Does every simple polygon admit a triangulation?

If yes, what is the number of triangles?

Does any triangulation lead to the same number of triangles?

By induction.

Existence

uw in the interior of P it is a diagonal.

w

P

v

Otherwise, the triangle determined

by u, v, w contains at least one

vertex. Let v be the one closest

to v. Then vv is a diagonal.

w

v

v

u

u

Theorem 1 Every simple polygon has a triangulation.

Any triangulation of a simple polygon with n

vertices consists of exactly n – 2 triangles.

Trivial for n = 3.

Assume true for all m < n.

Let v be the leftmost vertex and u and w its two neighbors.

The diagonal splits the polygon into two (which by induction can be triangulated).

Vertices defining the diagonal occur in each subpolygon

once.

# triangles = n – 2

Other vertices of P each occurs in exactly on one

subpolygon.

ProofAny diagonal splits P into two simple polygons with k and m

vertices, respectively.

By induction these two subpolygons can be triangulated.

They are decomposed into k – 2 and m – 2 triangles, resp.

Thus k + m = n + 2.

By induction, the triangulation of P has (k – 2) + (m – 2) = n – 2

triangles.

Theorem1 shows that any simple polygon with n vertices can be guarded with n-2 cameras.

But placing a camera inside every triangle seems OVERKILL.

A camera on a diagonal guards two triangles.

# cameras can be reduced to roughly n/2.

A vertex is adjacent to many triangles.

So placing cameras at vertices can do even better …

3-Coloring

Idea:Select a set of vertices, such that any triangle has at least one

selected vertex.

Assign each vertex a color:

pink, green, oryellow.

Any two vertices connected by

an edge or a diagonal must be

assigned different colors.

Thus the vertices of every triangle

will be in three different colors.

If 3-coloring exists, place cameras at all vertices of the same color.

Choose the smallest color class to place the cameras.

n/3 cameras.

A 3-Coloring Algorithm

A 3-coloring can be found through a graph traversal (such as DFS).

During DFS, maintain the invariant:

All polygon vertices of encountered

triangles have been colored such that

no adjacent two have the same color.

u

Start DFS at any node of G.

Color the three vertices of the

corresponding triangle.

v

Suppose node v is visited from u.

Their triangles T(v) and T(u) are adjacent.

Only one vertex of T(v) is not colored.

Its color is uniquely determined.

Since G is a tree, the other nodes adjacent to v have not been visited yet.

Otherwise there exists a cycle (which contradicts that G is a tree.)

Apply the color to v.

Art gallery theorem

Theorem: For a simple polygon with n vertices, n/3 cameras are occasionally necessary and always sufficient to have every point in the polygon visible from at least one of the cameras.

Can we do better?

A Worst Case

A triangulated polygon can always be 3-colored.

Any simple polygon can be guarded with n/3 cameras.

a

n/3 prongs

There exists no position at which a

camera can oversee two prongs.

n/3 cameras are needed.

The 3-coloring approach is optimal in the worst case.

1.Triangulate a simple polygon with a fast algorithm.

DCEL representation for the simple polygon so we can

visit a neighbor from a triangle in constant time.

2. Generate a 3-coloring by DFS (as presented earlier).

3. Take the smallest color class to place the cameras.

Solution to the Art Gallery ProblemTHEOREM

- Let P be a simple polygon with n vertices.A set of [n/3] camera positions in P such that any point inside P is visible from at least one of the cameras can be computed in O(n logn) time.

PARTITIONING A POLYGON INTO MONOTONE PİECES

- We have just seen that a triangulation of P always exists.the proof of that theorem is constructive and leads to a recursive triangulation algorithm:
- Find a diagonal and triuanglate the two resulting subpolygons recursively.

… The triangulation algorithm will take quadratic time in the worst case.

- Can we do better?

Convex polygon

- Pick one vertex of the

Polygon and draw diagonals

From this vertex to all other

vertices except

its neighbors.

This takes only linear time.

For a non-convex polygon unfortunately ,it is as difficult to partition a polygon into convex pieces as it is to trianglate it.Therefore we shall decompose P into so-called monotone pieces.

Monotone polygon

- A polygonP in the plane is called monotone with respect to a straight line L, if every line orthogonal to L intersects P at most twice.

Line sweep(top down)

- Vertices where the direction changes downward<> are called turn vertices.
- To have y-monotone pieces ,we need to get rid of turn vertices:
- When we encounter a turn vertex,it might be necessary to introduce a diagonal and split the polygon into pieces
- We will not add diagonals at all turn vertices

Types of Turn Vertices

If we want to define the different types of turn vertices carefully,we should pay special attention to vertices with equal y-coordinate.We do this by defining the notions of “below” and “above” as follows ; a point p is below another point q if

- Start Vertex - its two neighbors lie below it and the interior angle < 180°
- End Vertex - its two neighbors lie above it and the interior angle < 180°
- Split Vertex - its two neighbors lie below it and the interior angle > 180°
- Merge Vertex - its two neighbors lie above it and the interior angle > 180°

The split and merge vertices are sources of local non-monotonicity.The following stronger stament is true.

- LEMMA:A polygon is y-monotone if it has no split vertices or merge vertices.

Adding diagonals

* The partition p into y-monotone pieces , get rid of split and merge vertices

- Add a diagonal going upward each split vertex.
- Add a diagonal going downward from each merge vertex.

* Where do the edges go?

Helpers

- Let helper helper(ej) be the lowest vertex above the sweep-line
- Such that the horizontal segment connecting the vertex to ej lies inside P

Removing Split Vertices

- For a split vertex vi ,let be the edge immediately to the left of it.
- Add a diagonal from vi to helper ej

Removing merge vertex

- For a merge vertex vi let ej be edge immediately to the left of it
- vi becomes helper(ej ) ones we reach it
- Whenever the helper(ej ) is replaced by some vertex vm ,add a diagonal from vm to vi
- If vi is never replaced as helper(ej ), we can connect it to the lower endpoint of ej ..

Removing Split/Merge Vertices

- v1 … vn: a counter-clock enumeration of vertices of P
- e1 … en: a set of edges of P, where ei = segment (vi , vi+1)
- Events are stored in event queue, ordered by y-coord.
- If a split vertex, connect it to the lowest vertex (helper of its left edge) between the edges to its left and right
- If a merge vertex, connect it to the highest vertex between the edges to its left and right
- Store the edges (and their helpers) of P in the leaves of dynamic binary search tree T, left-to-right order reflects in order of leaves. Helpers may be replaced. Store only edges that have P to their right (or the left edges).

MakeMonotone(P)

Input: A simple polygon P stored in a doubly-connected edge list D

Output: A partitioning of P into monotone subpolygons stored in D

1.Construct a priority queue Q on the vertices of P, using their y-coordinates as priority. If two points have the same y-coordinates, the one with smaller x has higher priority

2. Initialize an empty binary search tree T

3. while Q is not empty

4. do Remove vi with the highest priority from Q

5. Call the appropriate procedure to handle the vertex,

depending on its type

HandleStartVertex(Vi)

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

HandleEndVertex(Vi)

- if helper(ei-1) is a merge vertex

2. then Insert diagonal connecting vi to helper(ei-1) in D

3. Delete ei-1 from T

HandleSplitVertex(Vi)

1. Search in T to find the edge ej directly left of vi

2. Insert diagonal connecting vi to helper(ej ) in D

3. helper(ej ) vi

4. Insert ei in T and set helper(ei ) to vi

HandleMergeVertex(Vi)

1. if helper(ei-1) is a merge vertex

2. then Insert diagonal connecting vi to helper(ei-1) in D

3. Delete ei-1 from T

4.Search in T to find the edge ejej directly left of vi

5.if helper(ej) is a merge vertex

6. then Insert diagonal connecting vi to helper(ej) in D

7. helper(ej ) vi

HandleRegularVertex(Vi)

1. if the interior of P lies to the right of vi

2. then if helper(ei-1) is a merge vertex

3. then Insert diag. connect 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 the edge ej directly left of vi

5.if helper(ej) is a merge vertex

6. then Insert diag. connect vi to helper(ej) in D

7. helper(ej ) vi

Partitioning Algorithm Analysis

- Construct priority queue: O(n)
- Initialize T: O(1)
- Handle an event: O(log n)
- one operation on Q: O(logn)
- at most 1 query, 1 insertion & 1 deletion on T: O(logn)
- insert at most 2 diagonals into D: O(1)
- Total run time: O(n log n)
- Storage: O(n)

An attempt was made to triangulate the following polygon, this time with respect to the horizontal, can you guess why the triangulation wasn\'t successful?

- Monotonic triangulation that failed because the polygon is not monotonic

After a slight modification to the polygon (it doesn\'t look like a donkey anymore), the polygon now looks like this and can be triangulated using the concept.

A successful monotonic triangulation of the modified polygon

LEMMA

- Algorithm MAKE MONOTONE adds set of non-intersecting diagonals that partitions P into monotone subpolygons.

Proof:

- We shall prove for the segment added in HANDLE-SPLİT-VERTEX ; the proof for the segments added in HANDLE-END-VERTEX,HANDLE-REGULAR-VERTEX,and HANDLE-MERGE-VERTEX is similar.
- We assume that no two vertices have the same y-coordinate.

Consider a segment vmvi that is added by HANDLE-SPLİT-VERTEX when vi is reached.

- Let ejbe the edge to the left of vi and let
- Be the edge to right of vi .Thus helper(ej)= vm

When we reach vi .

- We first argue that vmvi does not intersect an edge of P.
- To see this, consider the quadrilateral

Q bounded by the horizantel lines through vmand vi, and by ej and ek.There are no vertices of P inside Q, otherwise vm would not be the helper of ej .

It is supposed that there would be an edge of P intersecting vmvi.Since the edge cannot have an endpoint inside Q and polygon edges do not intersect each other, it would have to intersect the horizontal segment connecting vm to ej or the horizontel segment connecting vi to ej .Both are impossible, since for both vm and vi, the edge ej lies immediately to the left.Hence, no edge of P can intersect vmvi.

Since there are no vertices of P inside Q, and any previously added diagonal must have both of its endpoints above vi

it can can not intersect vmvi.

Triangulating a Monotone Polygon

- The main idea behind the algorithm is quite simple. First the vertices are sorted with respect to the line of monotonicity, which in the first case is the y-axis (which involves sorting the vertices by their y-coordinate), and in the second case it is the x-axis. Sorting becomes more complex when the line of monotonicity is neither the x nor the y-axis, yet it is not impossible. However, finding the line of monotonicity can be quite difficult to implement. This issue requires more effort and it lies beyond the scope of this report. After sorting the vertices from top to bottom, the triangles are cut off from the top.

Triangulation Algorithm Analysis

- A strictly y-montone polygon with n vertices can be triangulated in linear time
- A simple polygon with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage
- A planar subdivision with n vertices can be triangulated in O(n log n) time with an algorithm that uses O(n) storage

Triangulation History

1. A really naive algorithm is O(n*4): check all

n*2 choices for a diagonal, each in O(n)

time. Repeat this n ¡ 1 times.

2. A better naive algorithm is O(n*2); find an

ear in O(n) time; then recurse.

3. First non-trivial algorithm: O(n log n)

[GJPT-78]

4. A long series of papers and algorithms in

80s until Chazelle produced an optimal

O(n) algorithm in 1991.

5. Linear time algorithm insanely

complicated; there are randomized,

expected linear time that are more

accessible.

6. We content ourselves with O(n log n)

MORE…

- Computational Geometry-algorithms and applications
- http://www.me.cmu.edu/faculty1/shimada/cg97/bader/index.html
- http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Thierry/thierry507webprj/artgallery.html

DANKE SCHÖN…

TEŞEKKÜRLER…

Download Presentation

Connecting to Server..