universitat politcnica de catalunya facultat d'informatica...

266
Vera Sacrist´ an Computational Geometry Facultat d’Inform` atica de Barcelona Universitat Politcnica de Catalunya TRIANGULATING POLYGONS

Upload: others

Post on 17-Feb-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Vera Sacristan

Computational Geometry

Facultat d’Informatica de Barcelona

Universitat Politcnica de Catalunya

TRIANGULATING POLYGONS

Page 2: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 3: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 4: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 5: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 6: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 7: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 8: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 9: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

Page 10: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 11: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 12: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 13: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 14: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 15: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

A polygon triangulation is the decomposition of a polygon into triangles. This is done byinserting internal diagonals.

An internal diagonal is any segment...

• connecting two vertices of the polygon and

• completely enclosed in the polygon.

An application example:

Page 16: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TRIANGULATING POLYGONS

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Index

1. Every polygon can be triangulated

2. Properties of polygon triangulations

3. Algorithms

(a) Triangulating by inserting diagonals

(b) Triangulating by subtracting ears

(c) Triangulating convex polygons

(d) Triangulating monotone polygons

(e) Monotone partinioning

Page 17: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 18: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 19: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

The vertex p with minimum x-coordinate (and, if there are morethan one, the one with minimumy-coordinate) is convex.

p

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 20: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

The vertex p with minimum x-coordinate (and, if there are morethan one, the one with minimumy-coordinate) is convex.

p

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 21: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

The vertex p with minimum x-coordinate (and, if there are morethan one, the one with minimumy-coordinate) is convex.

So is the vertex q with maximumx-coordinate (which is different ofthe one with minimum one).

p

q

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 22: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

The vertex p with minimum x-coordinate (and, if there are morethan one, the one with minimumy-coordinate) is convex.

So is the vertex q with maximumx-coordinate (which is different ofthe one with minimum one).

Finally, there is at least one vertexwhich is extreme in the directionorthogonal to pq and does not co-incide with any of the above. Thisthird vertex r is necessarily convex.

p

q

r

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 23: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 24: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

Let vi be a convex vertex.

Then, either vi−1vi+1 is an internal diagonal...

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

vi

vi−1

vi+1

Page 25: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

or there exists a vertex of the polygon lying inthe triangle vi−1vivi+1.

Let vi be a convex vertex.

Then, either vi−1vi+1 is an internal diagonal...

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

vi

vi−1

vi+1

Page 26: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

or there exists a vertex of the polygon lying inthe triangle vi−1vivi+1.

Let vi be a convex vertex.

Then, either vi−1vi+1 is an internal diagonal...

In this case, among all the vertices ly-ing in the triangle, let vj be the farthestone from the segment vi−1vi+1. Thenvivj is an internal diagonal (it can notbe intersected by any edge of the poly-gon).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

vi

vi−1

vi+1

vj

Page 27: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

or there exists a vertex of the polygon lying inthe triangle vi−1vivi+1.

Let vi be a convex vertex.

Then, either vi−1vi+1 is an internal diagonal...

In this case, among all the vertices ly-ing in the triangle, let vj be the farthestone from the segment vi−1vi+1. Thenvivj is an internal diagonal (it can notbe intersected by any edge of the poly-gon).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

vi

vi−1

vi+1

vj

Page 28: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Every polygon admits a triangulation

Lemma 1. Every polygon has at least one convex vertex (actually, at least three).

Lemma 2. Every n-gon with n ≥ 4 has at least one internal diagonal.

Corollary. Every polygon can be triangulated. (By induction.)

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 29: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 30: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 31: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Proof by induction.

Base case: When n = 3, the number of diagonals is d = 0 = n− 3.

Inductive step: Consider a diagonal of a triangulation T of P , decomposing P into twosubpolygons: a (k + 1)-gon P1 and an (n − k + 1)-gon P2. By inductive hypothesis, thenumber of diagonals of the triangulations induced by T in P1 and P2 are:

d1 = k + 1− 3,d2 = n− k + 1− 3,

therefore, d = d1 + d2 + 1 = k + 1− 3 + n− k + 1− 3 + 1 = n− 3.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

P1P2

Page 32: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 33: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Again, the proof is by induction.

Base case: When n = 3, the number of triangles is t = 1 = n− 2.

Inductive step: With the same conditions of the previous proof,

t1 = k + 1− 2,t2 = n− k + 1− 2,

hence,t = t1 + t2 = k + 1− 2 + n− k + 1− 2 = n− 2.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

P1P2

Page 34: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Property 3. The dual graph of any triangulation of P is a tree.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 35: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Property 3. The dual graph of any triangulation of P is a tree.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Given a triangulation of P , its dual graph has one vertex for each trian-gle, and one edge connecting two vertices whenever their correspondingtriangles are adjacent. We want to prove that this graph is connected andacyclic.

Page 36: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Property 3. The dual graph of any triangulation of P is a tree.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Given a triangulation of P , its dual graph has one vertex for each trian-gle, and one edge connecting two vertices whenever their correspondingtriangles are adjacent. We want to prove that this graph is connected andacyclic.

Page 37: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Property 3. The dual graph of any triangulation of P is a tree.

Given a triangulation of P , its dual graph has one vertex for each trian-gle, and one edge connecting two vertices whenever their correspondingtriangles are adjacent. We want to prove that this graph is connected andacyclic.

The graph is trivially connected.

About the acyclicity: Notice that each edge of the dual graph “separates”the two endpoints of the internal diagonal of P shared by the two adjacenttriangles. If the graph had a cycle, it would enclose the endpoint(s) of thediagonals intersected by the cycle and, therefore, it would enclose pointsbelonging to the boundary of the polygon, contradicting the hypothesisthat P is simple and without holes.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 38: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Properties of the triangulations of polygons

Let P be a simple n-gon.

Property 1. Every triangulation of P has n− 3 diagonals.

Property 2. Every triangulation of P has n− 2 triangles.

Property 3. The dual graph of any triangulation of P is a tree.

Corollary. Every n-gon with n ≥ 4 has at least two non-adjacent ears.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 39: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

ALGORITHMS FORPOLYGON TRIANGULATION

Page 40: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 41: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 42: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 43: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Running time

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 44: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Running timeDetecting whether a vertex is convex: O(1).

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 45: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Running timeDetecting whether a vertex is convex: O(1).Detecting whether a convex vertex is an ear: O(n).

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 46: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Running timeDetecting whether a vertex is convex: O(1).Detecting whether a convex vertex is an ear: O(n).Finding an ear: O(n2).

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 47: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Running timeDetecting whether a vertex is convex: O(1).Detecting whether a convex vertex is an ear: O(n).Finding an ear: O(n2).

Overall running time:

T (n) = O(n2) +O((n− 1)2) +O((n− 2)2) + · · ·+O(1) = O(n3).

Procedure1. Sequentially explore the vertices until you find an ear2. Crop it3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 48: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Improved procedureInitialization

1. Detect all convex vertices2. Detect all ears

Next step1. Crop an ear2. Update the information of the convex vertices3. Update the information of the ears

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 49: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Improved procedureInitialization

1. Detect all convex vertices2. Detect all ears

Next step1. Crop an ear2. Update the information of the convex vertices3. Update the information of the ears

Running time

O(n)O(n2)

O(1)O(1)O(n)

Only once

O(n) times

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 50: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by subtracting ears

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Improved procedureInitialization

1. Detect all convex vertices2. Detect all ears

Next step1. Crop an ear2. Update the information of the convex vertices3. Update the information of the ears

Running time

Running time: O(n2)

O(n)O(n2)

O(1)O(1)O(n)

Only once

O(n) times

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 51: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 52: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 53: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 54: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 55: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Check vivj against all segments vkvk+1 for intersection.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 56: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Is it internal?

Check vivj against all segments vkvk+1 for intersection.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 57: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Is it internal?

Check vivj against all segments vkvk+1 for intersection.

If vi is convex, the oriented line −−→vivj should leavevi−1 to its left and vi+1 to its right.

vi

vi−1

vi+1

vj

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 58: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Is it internal?

Check vivj against all segments vkvk+1 for intersection.

If vi is convex, the oriented line −−→vivj should leavevi−1 to its left and vi+1 to its right.

If vi is reflex, the oriented line −−→vivj should not leavevi−1 to its right and vi+1 to its left.

vi

vi−1

vi+1

vj

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 59: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Is it internal?

Check vivj against all segments vkvk+1 for intersection.

If vi is convex, the oriented line −−→vivj should leavevi−1 to its left and vi+1 to its right.

If vi is reflex, the oriented line −−→vivj should not leavevi−1 to its right and vi+1 to its left.

Running time

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 60: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Is it a diagonal?

Is it internal?

Check vivj against all segments vkvk+1 for intersection.

If vi is convex, the oriented line −−→vivj should leavevi−1 to its left and vi+1 to its right.

If vi is reflex, the oriented line −−→vivj should not leavevi−1 to its right and vi+1 to its left.

Running time

O(n)

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 61: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 62: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 63: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Apply the test to each candidate segment.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 64: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Apply the test to each candidate segment.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

O(n3)

Page 65: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Apply the test to each candidate segment.

Testing each candidate takes O(n) time,and there are

(n2

)of them.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

O(n3)

Page 66: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Apply the test to each candidate segment.

Applying previous results:

1. Find a convex vertex, vi.2. Detect whether vi−1vi+1 is an internal diagonal.3. If so, report it.

Else, find the farthest vk from the segment vi−1vi+1, lying in the triangle vi−1vivi+1.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

O(n3)

Page 67: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal?

Brute-force solution:

Apply the test to each candidate segment.

Applying previous results:

1. Find a convex vertex, vi.2. Detect whether vi−1vi+1 is an internal diagonal.3. If so, report it.

Else, find the farthest vk from the segment vi−1vi+1, lying in the triangle vi−1vivi+1.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

O(n3)

O(n)

Page 68: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal? O(n)

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 69: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal? O(n)

Partition. How to partition the polygon into two subpolygons?

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 70: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal? O(n)

Partition. How to partition the polygon into two subpolygons?

From the diagonal found, create the sorted list of the vertices of the two subpolygons.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 71: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal? O(n)

Partition. How to partition the polygon into two subpolygons?

From the diagonal found, create the sorted list of the vertices of the two subpolygons.

O(n)

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 72: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Tringulating a polygon by inserting diagonals

Test. How to decide whether a given segment vivj is an internal diagonal?

Running time

O(n)

Search. How to find an internal diagonal? O(n)

Partition. How to partition the polygon into two subpolygons? O(n)

Total running time of the algorithm: O(n2)

It finds n− 3 diagonals and each one is found in O(n) time.

Procedure:1. Find an internal diagonal2. Decompose the polygon into two subpolygons3. Proceed recursively

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Input: v1, . . . , vn, sorted list of the vertices of a simple polygon P .

Output: List of internal diagonals of P , vivj , determining a triangulation of P .

Page 73: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 74: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 75: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 76: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 77: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 78: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 79: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 80: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 81: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 82: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 83: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 84: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 85: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 86: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 87: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 88: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 89: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Triangulating a star-shaped polygon

Can be done in O(n) time. Posed as problem.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 90: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Is it possible to triangulate a polygon more efficiently?

Triangulating a convex polygon

Trivially done in O(n) time.

Triangulating a monotone polygon

It can also be done in O(n) time. In the following we will see how.

Triangulating a star-shaped polygon

Can be done in O(n) time. Posed as problem.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 91: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 92: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 93: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

y

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 94: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

y

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 95: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

y

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 96: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 97: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 98: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Proof:

If the polygon has a local maximum cusp v, an infinitesimaldownwards translation of the horizontal line through v wouldintersect the polygon in at least two connected components.

v

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 99: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Proof:

If the polygon has a local maximum cusp v, an infinitesimaldownwards translation of the horizontal line through v wouldintersect the polygon in at least two connected components.

If the polygon is not y-monotone, let r be a horizontal line intersecting the polygon in two ormore connected components. Consider two consecutive components, with facing endpoints pand q as in the figure. The polygon boundary needs to connect p and q. No matter whether itgoes above or below the horizontal line, it will have a cusp.

p q

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 100: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Proof:

If the polygon has a local maximum cusp v, an infinitesimaldownwards translation of the horizontal line through v wouldintersect the polygon in at least two connected components.

If the polygon is not y-monotone, let r be a horizontal line intersecting the polygon in two ormore connected components. Consider two consecutive components, with facing endpoints pand q as in the figure. The polygon boundary needs to connect p and q. No matter whether itgoes above or below the horizontal line, it will have a cusp.

p q

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 101: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Proof:

If the polygon has a local maximum cusp v, an infinitesimaldownwards translation of the horizontal line through v wouldintersect the polygon in at least two connected components.

If the polygon is not y-monotone, let r be a horizontal line intersecting the polygon in two ormore connected components. Consider two consecutive components, with facing endpoints pand q as in the figure. The polygon boundary needs to connect p and q. No matter whether itgoes above or below the horizontal line, it will have a cusp.

p q

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 102: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 103: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Monotone polygon

A polygon P is called monotone with respect to a direction r if, forevery line r′ orthogonal to r, the intersection P ∩ r′ is connected (i.e.,it is a segment, a point or the empty set).

y

Local characterization

A polygon is y-monotone if and only if it does not have any cusp.

A cusp is a reflex vertex v of the polygon such that its twoincident edges both lie to the same side of the horizontal linethrough v.

Corollary

If a polygon is y-monotone, then it can be decomposed into twoy-monotone non intersecting chains sharing their endpoints.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 104: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 105: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 106: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

1234

5

76

8 910

1112

1314 15

1617

18 19

P ′

Page 107: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

1234

5

76

8 910

1112

1314 15

1617

18 19

P ′

Page 108: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

• If vi belongs to the opposite chain, report the diagonals con-necting vi to every vertex of Q and delete them all from Q,except the last one. Add vi to Q.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 109: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

• If vi belongs to the opposite chain, report the diagonals con-necting vi to every vertex of Q and delete them all from Q,except the last one. Add vi to Q.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 110: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

• If vi belongs to the opposite chain, report the diagonals con-necting vi to every vertex of Q and delete them all from Q,except the last one. Add vi to Q.

• If vi belongs to the same chain and produces a reflex turn,add vi to Q.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 111: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

• If vi belongs to the opposite chain, report the diagonals con-necting vi to every vertex of Q and delete them all from Q,except the last one. Add vi to Q.

• If vi belongs to the same chain and produces a reflex turn,add vi to Q.

• If vi belongs to the same chain and produces a convex turn,report the diagonal connecting vi to the penultimate elementof Q, delete the last element of Q and process vi again.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 112: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Triangulating a monotone polygon

The vertices of the polygon P are processed by decreasing order of their y-coordinate.

During the process a queue Q is used to store the vertices that have already been visited butare still needed in order to generate the triangulation. Characteristics of Q:

- The topmost (i.e., largest y-coordinate) vertex in Q, is a convex vertex of the subpolygonP ′ still to be triangulated.

- All the remaining vertices in Q are reflex.- All the vertices in Q belong to the same monotone chain of P ′.

Processing a vertex vi:

• If vi belongs to the opposite chain, report the diagonals con-necting vi to every vertex of Q and delete them all from Q,except the last one. Add vi to Q.

• If vi belongs to the same chain and produces a reflex turn,add vi to Q.

• If vi belongs to the same chain and produces a convex turn,report the diagonal connecting vi to the penultimate elementof Q, delete the last element of Q and process vi again.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 113: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18 19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 114: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Queue state

1, 2

19

Start

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 115: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

3

1, 2, 3

19

Add

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 116: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

4

1, 2, 3, 4

19

Add

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 117: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

5

1, 2, 3, 4, 5

19

Add

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 118: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

6

1, 2, 3, 4, 5, 6

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Add

Page 119: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

7

6, 7

19

Opposite chain

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 120: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

8

6, 8

19

Ear

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 121: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

9

6, 9

19

Ear

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 122: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

10

6, 9, 10

19

Add

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 123: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

11

6, 9, 10, 11

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Add

Page 124: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

12

6, 9, 10, 11, 12

19

Add

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 125: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

13

6, 9, 10, 13

19

Ear

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 126: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

14

6, 9, 10, 14

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Ear

Page 127: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

15

14, 15

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Opposite chain

Page 128: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

16

15, 16

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Opposite chain

Page 129: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

17

15, 17

19

Ear

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 130: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

18

15, 18

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Ear

Page 131: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18

Current vertex:

Queue state:

19

18, 19

19

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Opposite chain

Page 132: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18 19

End

Triangulating a monotone polygon

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 133: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

34

5

7

6

89

10

1112

13

1415

16

17

18 19

Triangulating a monotone polygon

Running time: O(n)

Each vertex is removed fromthe queue Q in O(1) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 134: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Running time for triangulating a polygon:

• O(n2) by subtracting ears

• O(n2) by inserting diagonals

If the polygon is convex:

• O(n) trivially

If the polygon is monotone:

• O(n) scanning the monotone chains in order

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Summarizing

Page 135: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Running time for triangulating a polygon:

• O(n2) by subtracting ears

• O(n2) by inserting diagonals

If the polygon is convex:

• O(n) trivially

If the polygon is monotone:

• O(n) scanning the monotone chains in order

Is it possible to be more efficient more general polygons?

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Summarizing

Page 136: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Running time for triangulating a polygon:

• O(n2) by subtracting ears

• O(n2) by inserting diagonals

If the polygon is convex:

• O(n) trivially

If the polygon is monotone:

• O(n) scanning the monotone chains in order

1. Decompose the polygon into monotone subpolygons

2. Triangulate the monotone subpolygons

Is it possible to be more efficient more general polygons? Yes!

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Summarizing

Page 137: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 138: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 139: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 140: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 141: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 142: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 143: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 144: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 145: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 146: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 147: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 148: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

Page 149: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

This can be done starting from atrapezoidal decomposition of the polygon.

Connect each cusp with the opposite vertex in itstrapezoid (the upper trapezoid, if the cusp is a localmaximum, the lower one, if it is a local minimum).

Sweep line algorithm

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In order to create a monotone partition of a polygon,all cusps need to be “broken” by internal diagonals.

This gives rise to a correct algorithm:

• The diagonals do not intersect, because theybelong to different trapezoids.

• The polygon ends up decomposed into mono-tone subpolygons.

Page 150: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Sweep line algorithm

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 151: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Sweep line algorithm

A straight line (horitzontal, in this case) scans the object (the polygon) and allows detectingand constructing the desired elements (cusps, trapezoids, diagonals), leaving the problem solvedbehind it. The sweeping process is discretized.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 152: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Sweep line algorithm

A straight line (horitzontal, in this case) scans the object (the polygon) and allows detectingand constructing the desired elements (cusps, trapezoids, diagonals), leaving the problem solvedbehind it. The sweeping process is discretized.

Essential elements of a sweep line algorithm:

• Events queue

Priority queue keeping the information of the algorithm stops. In our problem, the eventswill be the vertices of the polygon, sorted by their y-coordinate, all known in advance.

• Sweep line

Data structure storing the information of the portion of the object intersected by thesweep line. It gets updated at each event. In our problem, it will contain the informationof the edges of the polygon intersected by the sweep line, sorted by abscissa, as well asthe list of active trapezoids and ther upper vertex.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 153: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 154: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 155: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1

ei ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 156: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1ei

ejek

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 157: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em eneiei−1ek ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 158: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em enei−1ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 159: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1 ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 160: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 161: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1

ei ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 162: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1ei

ejek

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 163: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em eneiei−1ek ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 164: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em enei−1ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 165: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Updating the sweep line:

• Passing vertex: replace

• Local minimum cusp: delete

• Local maximum cusp: insert

• Initial vertex: insert

• Final vertex: delete

em en

ei−1 ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

In addition, eventually updatethe information of the upper ver-tex of the starting trapezoid.

Page 166: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 167: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

em en

ei−1

ei ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 168: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

em en

ei−1ei

ejek

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 169: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

em eneiei−1ek ej

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 170: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

em enei−1ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 171: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

As for diagonals:

• Passing vertex: nothing

• Local minimum cusp: wait until it can be connect to the final vertex of the startingtrapezoid

• Local maximum cusp: connect it with the initial vertex of the ending trapezoid

• Initial vertex: nothing

• Final vertex: nothing

em en

ei−1 ei

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 172: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

1

vertex

sweep line

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e1, e19

v1

Page 173: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

18

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e18, e17

e1, e19

v1

v18

Page 174: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

3

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e2, e3

e1, e19, e18, e17

v1 v18

Page 175: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

3

Diagonal v1− v3

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e2, e3

e1, e19, e18, e17

v1 v18

Page 176: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

19

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e1, e2, e3, e19, e18, e17

v3 v3 v18

Page 177: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

2

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e1, e2, e3, e17

v3 v19

Page 178: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

17

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e3, e17

e16

v19

Page 179: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

17

Diagonal v19− v17

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e3, e17

e16

v19

Page 180: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

15

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e3, e16

e15, e14

v17

v15

Page 181: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

16

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e3, e16, e15, e14

v17 v15

Page 182: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

5

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e3, e14

e5, e4

v16

v5

Page 183: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

6

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e5, e4, e3, e14

e6

v5 v16

Page 184: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

7

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e6, e4, e3, e14

e7

v6 v16

Page 185: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

14

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e4, e3, e14

e13

v7 v16

Page 186: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

14

Diagonal v16− v14

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e4, e3, e14

e13

v7 v16

Page 187: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

4

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e4, e3, e13

v7 v14

Page 188: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

9

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e13

e8, e9

v4

Page 189: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

9

Diagonal v4− v9

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e13

e8, e9

v4

Page 190: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

13

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e8, e9, e13

e12

v9 v9

Page 191: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

8

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e7, e8, e9, e12

v9 v13

Page 192: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

11

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e9, e12

e10, e11

v13

Page 193: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

11

Diagonal v13− v11

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e9, e12

e10, e11

v13

Page 194: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

12

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

e9, e10, e11, e12

v11 v11

Page 195: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

vertex

sweep line

10

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

v11

e9, e10

Page 196: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 197: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 198: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1516

17

18

19Running time:

• Sorting the vertices in the event queue:O(n log n) time.

• On each event, update sweep line: replace,insert or delete vertices or edges in O(log n)time each.

• There are n events.

The algorithm runs in O(n log n) time.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Monotone partition

Page 199: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Summarizing

Running time of polygon triangulation:

• O(n2) by substracting ears

• O(n2) by inserting diagonals

• O(n log n) by:

1. Decomposing the polygon into monotone subpolygons in O(n log n) time

2. Triangulating each monotone subpolygon in O(n) time

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 200: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Summarizing

Running time of polygon triangulation:

• O(n2) by substracting ears

• O(n2) by inserting diagonals

• O(n log n) by:

1. Decomposing the polygon into monotone subpolygons in O(n log n) time

2. Triangulating each monotone subpolygon in O(n) time

Is it possible to triangulate a polygon in o(n log n) time?

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 201: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Summarizing

Running time of polygon triangulation:

• O(n2) by substracting ears

• O(n2) by inserting diagonals

• O(n log n) by:

1. Decomposing the polygon into monotone subpolygons in O(n log n) time

2. Triangulating each monotone subpolygon in O(n) time

Is it possible to triangulate a polygon in o(n log n) time?

Yes.There exists an algorithm to triangulate an n-gon in O(n) time, but it is too complicatedand, in practice, it is not used.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 202: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

STORING THEPOLYGON TRIANGULATION

Page 203: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Page 204: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Storing the list of all the diagonals of the triangulation

Page 205: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Storing the list of all the diagonals of the triangulation

Advantage: small memory usage.

Disadvantage: it suffices to draw the triangulation, but it does not contain the proximityinformation. For example, finding the triangles incident to a given diagonal, or finding theneighbors of a given triangle are expensive computations.

Page 206: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Storing the list of all the diagonals of the triangulation

Advantage: small memory usage.

Disadvantage: it suffices to draw the triangulation, but it does not contain the proximityinformation. For example, finding the triangles incident to a given diagonal, or finding theneighbors of a given triangle are expensive computations.

For each triangle, storing the sorted list of its vertices and edges, as well as the sorted list ofits neighbors.

Page 207: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Storing the list of all the diagonals of the triangulation

Advantage: small memory usage.

Disadvantage: it suffices to draw the triangulation, but it does not contain the proximityinformation. For example, finding the triangles incident to a given diagonal, or finding theneighbors of a given triangle are expensive computations.

For each triangle, storing the sorted list of its vertices and edges, as well as the sorted list ofits neighbors.

Advantage: allows to quickly recover neighborhood information.

Disadvantage: the stored data is redundant and it uses more space than required.

Page 208: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Possible options, advantages and disadvantages

Storing the list of all the diagonals of the triangulation

Advantage: small memory usage.

Disadvantage: it suffices to draw the triangulation, but it does not contain the proximityinformation. For example, finding the triangles incident to a given diagonal, or finding theneighbors of a given triangle are expensive computations.

For each triangle, storing the sorted list of its vertices and edges, as well as the sorted list ofits neighbors.

Advantage: allows to quickly recover neighborhood information.

Disadvantage: the stored data is redundant and it uses more space than required.

The data structure which is most frequently used to store a triangulation is the DCEL (doublyconnected edge list).

The DCEL is also used to store plane partitions, polyhedra, meshes, etc.

Page 209: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 210: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 211: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6

v7

v8

v9

Page 212: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

Page 213: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

f∞

f5

f4

f1

f3

f6

f2

f7

Page 214: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6

v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6

f2

f7

Page 215: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 216: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Table of vertices

v x y e

1 x1 y1 12 x2 y2 13 x3 y3 24 x4 y4 105 x5 y5 46 x6 y6 67 x7 y7 108 x8 y8 89 x9 y9 9

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 217: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

f e

1 112 43 104 115 16 67 2∞ 9

Table of faces

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 218: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 22 2 3 7 ∞ 13 33 4 3 ∞ 7 4 24 4 5 2 ∞ 15 55 5 6 2 ∞ 4 66 6 7 6 ∞ 15 77 7 8 4 ∞ 11 88 8 9 4 ∞ 7 99 9 1 5 ∞ 12 1

10 4 7 3 6 13 611 9 7 4 1 8 1412 2 9 5 1 1 1113 2 4 3 7 14 314 2 7 1 3 12 1015 4 6 6 2 10 5

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 219: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

e

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 220: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

e

vE

vB

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 221: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

e

vE

vB

fL

fR

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 222: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

e

vE

vB

fL

fR

eN

eP

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 223: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 22 2 3 7 ∞ 13 33 4 3 ∞ 7 4 24 4 5 2 ∞ 15 55 5 6 2 ∞ 4 66 6 7 6 ∞ 15 77 7 8 4 ∞ 11 88 8 9 4 ∞ 7 99 9 1 5 ∞ 12 1

10 4 7 3 6 13 611 9 7 4 1 8 1412 2 9 5 1 1 1113 2 4 3 7 14 314 2 7 1 3 12 1015 4 6 6 2 10 5

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

e

vE

vB

fL

fR

eN

eP

Page 224: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Storage space

• For each face:

1 pointer

• For each vertex:

2 coordinates + 1 pointer

• For each edge:

6 pointers

In total, the storage space is O(n).

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 225: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

There are other DCEL variants, as for example:

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 226: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

There are other DCEL variants, as for example:

ee′

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 227: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

There are other DCEL variants, as for example:

ee′

e −→ vB , fR, eN , e′

e′ −→ vB , fR, eN , e

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 228: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

There are other DCEL variants, as for example:

ee′

e −→ vB , fR, eN , e′

e′ −→ vB , fR, eN , e

vB(e)

fR(e)

eN (e)

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 229: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

There are other DCEL variants, as for example:

ee′

e −→ vB , fR, eN , e′

e′ −→ vB , fR, eN , e

vB(e)

fR(e)

eN (e)vB(e

′)

fR(e′)

eN (e′)

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

Page 230: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 231: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 22 2 3 7 ∞ 13 33 4 3 ∞ 7 4 24 4 5 2 ∞ 15 55 5 6 2 ∞ 4 66 6 7 6 ∞ 15 77 7 8 4 ∞ 11 88 8 9 4 ∞ 7 99 9 1 5 ∞ 12 1

10 4 7 3 6 13 611 9 7 4 1 8 1412 2 9 5 1 1 1113 2 4 3 7 14 314 2 7 1 3 12 1015 4 6 6 2 10 5

Page 232: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

DCEL

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

e vB fR eN e′

1 1 ∞ 2 1’2 2 ∞ 3 2’3 4 7 2 3’4 4 ∞ 5 4’5 5 ∞ 6 5’6 6 ∞ 7 6’7 7 ∞ 8 7’8 8 ∞ 9 8’9 9 ∞ 1 9’

10 4 6 6 10’11 9 1 14 11’12 2 1 11 12’13 2 7 3 13’14 2 3 10 14’15 4 2 5 15’1’ 2 5 9 12’ 3 7 13 23’ 3 ∞ 4 34’ 5 2 15 4

5’ 6 2 4 56’ 7 6 15 67’ 8 4 11 78’ 9 4 7 89’ 1 5 12 9

10’ 7 3 13 1011’ 7 4 8 1112’ 9 5 1 1213’ 4 3 14 1314’ 7 1 12 1415’ 6 6 10 15

Page 233: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Page 234: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

Page 235: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Page 236: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

Page 237: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

Table of vertices

v x y e

1 x1 y1 12 x2 y2 23 x3 y3 34 x4 y4 45 x5 y5 56 x6 y6 67 x7 y7 78 x8 y8 89 x9 y9 9

Page 238: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

f e

∞ 9

Table of faces

Page 239: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

DCEL

e vB vE fL fR eP eN

1 1 2 ∞ 22 2 3 ∞ 33 3 4 ∞ 44 4 5 ∞ 55 5 6 ∞ 66 6 7 ∞ 77 7 8 ∞ 88 8 9 ∞ 99 9 1 ∞ 1

Page 240: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

e vB vE fL fR eP eN

1 1 2 ∞ 22 2 3 ∞ 33 4 3 ∞ 44 4 5 ∞ 55 5 6 ∞ 66 6 7 ∞ 77 7 8 ∞ 88 8 9 ∞ 99 9 1 ∞ 1

DCEL

Page 241: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

Advance

v1

v2

v9

e1

e9

Page 242: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

Advance

f5e12

v1

v2

v9

e1

e9

Page 243: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

Advance

f5e12

v1

v2

v9

e1

e9

f e

5 9

Table of faces

Page 244: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 1: substracting ears

Advance

f5e12

v1

v2

v9

e1

e9

f e

5 9

Table of faces

DCEL

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 29 9 1 5 ∞ 12 1

12 2 9 5 1

Page 245: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

Page 246: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Page 247: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

Page 248: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

Table of vertices

v x y e

1 x1 y1 12 x2 y2 23 x3 y3 34 x4 y4 45 x5 y5 56 x6 y6 67 x7 y7 78 x8 y8 89 x9 y9 9

Page 249: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

f∞

Initialize

f e

∞ 9

Table of faces

Page 250: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v7

v6

v4

e6

e10f6

e15

Base step

Page 251: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v7

v6

v4

e6

e10f6

e15

Base step

f e

6 10

Table of faces

Page 252: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

v7

v6

v4

e6

e10f6

e15

Base step

f e

6 10

Table of faces

DCEL

e vB vE fL fR eP eN

6 6 7 6 ∞ 15 1010 7 4 6 ∞ 6 1515 4 6 6 ∞ 10 6

Page 253: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

Merge step

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

Page 254: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

Merge step

DCEL 1

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 1414 2 7 1 ∞ 12 7

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

DCEL 2

e vB vE fL fR eP eN

6 6 7 6 ∞ 15 1414 2 7 ∞ 3 2 10

Page 255: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

Merge step

DCEL 1

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 1414 2 7 1 ∞ 12 7

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

DCEL 2

e vB vE fL fR eP eN

6 6 7 6 ∞ 15 1414 2 7 ∞ 3 2 10

Page 256: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 2: inserting diagonals

Merge step

DCEL 1

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 1414 2 7 1 ∞ 12 7

v1

v2

v3

v4

v5

v6v7

v8

v9

e1

e2 e3

e4

e5

e6

e7

e8

e9

e10

e11

e12

e13

e14 e15

f∞

f5

f4

f1

f3

f6f2

f7

DCEL 2

e vB vE fL fR eP eN

6 6 7 6 ∞ 15 1414 2 7 ∞ 3 2 10

Merged DCEL

e vB vE fL fR eP eN

1 1 2 5 ∞ 9 26 6 7 6 ∞ 15 7

14 2 7 1 3 12 10

Page 257: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 3:

Page 258: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 3:

1. Decompose into monotone polygons

2. Triangulate monotone pieces

Page 259: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Storing the polygon triangulation

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

How to build the DCEL

Algorithm 3:

1. Decompose into monotone polygons

2. Triangulate monotone pieces

Computing the DCEL is done by combining previous strategies:

• Separating ears for triangulating each monotone subpolygon.

• Merging DCELs for putting together the monotone pieces.

Page 260: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

WHAT HAPPENS IN 3D?

Page 261: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

WHAT HAPPENS IN 3D?

A polyhedron that can be tetrahedralized :

Page 262: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

WHAT HAPPENS IN 3D?

A cube can be decomposed into 6 tetrahedra...

Page 263: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

WHAT HAPPENS IN 3D?

A cube can be decomposed into 6 tetrahedra...but also into 5!

Page 264: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

WHAT HAPPENS IN 3D?

A polyhedron that cannot be tetrahedralized:

Schonhardt polyhedron

Photo from pinshape.com (designed by mathgrrl)

Smallest polyhedron that cannot be tetrahedralized

Figure from the book by Devadoss and O’Rourke

Page 265: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TO LEARN MORE

• J. O’Rourke, Computational Geometry in C (2nd ed.), Cambridge University Press,1998.

• M. de Berg, O. Cheong, M. van Kreveld, M. Overmars, Computational Geometry:Algorithms and Applications (3rd rev. ed.), Springer, 2008.

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS

Page 266: Universitat Politcnica de Catalunya Facultat d'Informatica ...dccg.upc.edu/people/vera/wp-content/uploads/2013/06/GeoC-Triangulating... · the triangle v i 1 v i v i+1. Let v i be

TO LEARN MORE

• J. O’Rourke, Computational Geometry in C (2nd ed.), Cambridge University Press,1998.

• M. de Berg, O. Cheong, M. van Kreveld, M. Overmars, Computational Geometry:Algorithms and Applications (3rd rev. ed.), Springer, 2008.

A NICE APPLICATION

The art gallery theorem

• J. O’Rourke, Art Gallery Theorems and Algorithms, Oxford University Press, 1987.http://maven.smith.edu/∼orourke/books/ArtGalleryTheorems/art.html

Computational Geometry, Facultat d’Informatica de Barcelona, UPC

TRIANGULATING POLYGONS