polygon triangulation
Download
Skip this Video
Download Presentation
POLYGON TRIANGULATION

Loading in 2 Seconds...

play fullscreen
1 / 59

POLYGON TRIANGULATION - PowerPoint PPT Presentation


  • 215 Views
  • Uploaded on

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 .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
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

POLYGON TRIANGULATION

THE ART GALERY PROBLEM

SİNEM GETİR

2008-2009

COMPUTER GRAPHIC SEMINAR

FEBRUARY 4, 2009

contents
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
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
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
slide5

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
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
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.
triangulation1
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.

slide9

w

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?

slide10

Proof

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).

proof

Vertices defining the diagonal occur in each subpolygon

once.

# triangles = n – 2

Other vertices of P each occurs in exactly on one

subpolygon.

Proof

Any 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.

slide12

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
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 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
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 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.

solution to the art gallery problem

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 Problem
theorem
THEOREM
  • 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
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.
convex polygon
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.

slide23
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
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.
slide25
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
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°
slide28
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
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
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
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
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
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
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 v i
HandleStartVertex(Vi)

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

handleendvertex v i
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 v i
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 v i
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 v i
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
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)
slide47

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
slide48

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
LEMMA
  • Algorithm MAKE MONOTONE adds set of non-intersecting diagonals that partitions P into monotone subpolygons.
proof1
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.
slide51
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 .

slide52
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.
slide53
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
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
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
slide57
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)

slide58
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
slide59
DANKE SCHÖN…

TEŞEKKÜRLER…

ad