Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation...

32
Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Transcript of Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation...

Page 1: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Computational Geometry:Polygon triangulation

Panos Giannopoulos, Wolfgang Mulzer, Lena SchlipfAG TI

SS 2013

Page 2: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Outline

Doubly-connected edge list

Triangulating a simple polygon I

,FU Berlin, Computational Geometry:, SS 2013 2

Page 3: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Doubly-connected edge list (DCEL)

Representing a planar subdivision

Chapter 2LINE SEGMENT INTERSECTION

Figure 2.3Types of forest in Canada

to incorporate structural, topological information: which segments bound agiven region, which regions are adjacent, and so on.

The maps we consider are planar subdivisions induced by planar embeddingsof graphs. Such a subdivision is connected if the underlying graph is connected.The embedding of a node of the graph is called a vertex, and the embedding ofan arc is called an edge. We only consider embeddings where every edge is astraight line segment. In principle, edges in a subdivision need not be straight.A subdivision need not even be a planar embedding of a graph, as it may haveunbounded edges. In this section, however, we don’t consider such more generalsubdivisions. We consider an edge to be open, that is, its endpoints—which arevertices of the subdivision—are not part of it. A face of the subdivision is a

face

vertex

edge

disconnectedsubdivision

maximal connected subset of the plane that doesn’t contain a point on an edgeor a vertex. Thus a face is an open polygonal region whose boundary is formedby edges and vertices from the subdivision. The complexity of a subdivisionis defined as the sum of the number of vertices, the number of edges, and thenumber of faces it consists of. If a vertex is the endpoint of an edge, then wesay that the vertex and the edge are incident. Similarly, a face and an edge onits boundary are incident, and a face and a vertex of its boundary are incident.

What should we require from a representation of a subdivision? An opera-tion one could ask for is to determine the face containing a given point. Thisis definitely useful in some applications—indeed, in a later chapter we shalldesign a data structure for this—but it is a bit too much to ask from a basicrepresentation. The things we can ask for should be more local. For example, itis reasonable to require that we can walk around the boundary of a given face,or that we can access one face from an adjacent one if we are given a commonedge. Another operation that could be useful is to visit all the edges around agiven vertex. The representation that we shall discuss supports these operations.It is called the doubly-connected edge list.

A doubly-connected edge list contains a record for each face, edge, and vertex30

,FU Berlin, Computational Geometry:, SS 2013 3

Page 4: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Doubly-connected edge list (DCEL)Representing a planar subdivision

Polyhedra and Half Edge (or DCEL) data structure

Doubly-Connected Edge List:

Chapter 2LINE SEGMENT INTERSECTION

The half-edge record of a half-edge!e stores a pointer Origin(!e) to its origin,a pointer Twin(!e) to its twin half-edge, and a pointer IncidentFace(!e) tothe face that it bounds. We don’t need to store the destination of an edge,because it is equal to Origin(Twin(!e)). The origin is chosen such that

!e

Prev(!e)

Next(!e)

IncidentFace(!e)

Origin(!e)

Twin(!e)

IncidentFace(!e) lies to the left of !e when it is traversed from origin todestination. The half-edge record also stores pointers Next(!e) and Prev(!e)to the next and previous edge on the boundary of IncidentFace(!e). ThusNext(!e) is the unique half-edge on the boundary of IncidentFace(!e) that hasthe destination of!e as its origin, and Prev(!e) is the unique half-edge on theboundary of IncidentFace(!e) that has Origin(!e) as its destination.

A constant amount of information is used for each vertex and edge. A face mayrequire more storage, since the list InnerComponents( f ) has as many elementsas there are holes in the face. Because any half-edge is pointed to at most oncefrom all InnerComponents( f ) lists together, we conclude that the amount ofstorage is linear in the complexity of the subdivision. An example of a doubly-connected edge list for a simple subdivision is given below. The two half-edgescorresponding to an edge ei are labeled!ei,1 and!ei,2.

Vertex Coordinates IncidentEdgev1 (0,4) !e1,1v2 (2,4) !e4,2v3 (2,2) !e2,1v4 (1,1) !e2,2

!e1,1

!e1,2

!e2,1

!e2,2

!e3,1

!e3,2 !e4,2

!e4,1

v1 v2

v3

v4

f1

f2 Face OuterComponent InnerComponentsf1 nil !e1,1f2 !e4,1 nil

Half-edge Origin Twin IncidentFace Next Prev!e1,1 v1 !e1,2 f1 !e4,2 !e3,1!e1,2 v2 !e1,1 f2 !e3,2 !e4,1!e2,1 v3 !e2,2 f1 !e2,2 !e4,2!e2,2 v4 !e2,1 f1 !e3,1 !e2,1!e3,1 v3 !e3,2 f1 !e1,1 !e2,2!e3,2 v1 !e3,1 f2 !e4,1 !e1,2!e4,1 v3 !e4,2 f2 !e1,2 !e3,2!e4,2 v2 !e4,1 f1 !e2,1 !e1,1

The information stored in the doubly-connected edge list is enough to performthe basic operations. For example, we can walk around the outer boundaryof a given face f by following Next(!e) pointers, starting from the half-edgeOuterComponent( f ). We can also visit all edges incident to a vertex v. It is agood exercise to figure out for yourself how to do this.

We described a fairly general version of the doubly-connected edge list. Inapplications where the vertices carry no attribute information we could store32

É geometric andtopological informationstored in records(vertex, face, half-edge)

É two oriented half-edgesfor an edge (origin,distination)

É incident face of ahalf-edge lies to its left

É counterclockwisetraversal of a face

,FU Berlin, Lecture 3 (CGAL), WS 2012/13 10

,FU Berlin, Computational Geometry:, SS 2013 3

Page 5: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Doubly-connected edge list (DCEL)

Chapter 2LINE SEGMENT INTERSECTION

The half-edge record of a half-edge!e stores a pointer Origin(!e) to its origin,a pointer Twin(!e) to its twin half-edge, and a pointer IncidentFace(!e) tothe face that it bounds. We don’t need to store the destination of an edge,because it is equal to Origin(Twin(!e)). The origin is chosen such that

!e

Prev(!e)

Next(!e)

IncidentFace(!e)

Origin(!e)

Twin(!e)

IncidentFace(!e) lies to the left of !e when it is traversed from origin todestination. The half-edge record also stores pointers Next(!e) and Prev(!e)to the next and previous edge on the boundary of IncidentFace(!e). ThusNext(!e) is the unique half-edge on the boundary of IncidentFace(!e) that hasthe destination of!e as its origin, and Prev(!e) is the unique half-edge on theboundary of IncidentFace(!e) that has Origin(!e) as its destination.

A constant amount of information is used for each vertex and edge. A face mayrequire more storage, since the list InnerComponents( f ) has as many elementsas there are holes in the face. Because any half-edge is pointed to at most oncefrom all InnerComponents( f ) lists together, we conclude that the amount ofstorage is linear in the complexity of the subdivision. An example of a doubly-connected edge list for a simple subdivision is given below. The two half-edgescorresponding to an edge ei are labeled!ei,1 and!ei,2.

Vertex Coordinates IncidentEdgev1 (0,4) !e1,1v2 (2,4) !e4,2v3 (2,2) !e2,1v4 (1,1) !e2,2

!e1,1

!e1,2

!e2,1

!e2,2

!e3,1

!e3,2 !e4,2

!e4,1

v1 v2

v3

v4

f1

f2 Face OuterComponent InnerComponentsf1 nil !e1,1f2 !e4,1 nil

Half-edge Origin Twin IncidentFace Next Prev!e1,1 v1 !e1,2 f1 !e4,2 !e3,1!e1,2 v2 !e1,1 f2 !e3,2 !e4,1!e2,1 v3 !e2,2 f1 !e2,2 !e4,2!e2,2 v4 !e2,1 f1 !e3,1 !e2,1!e3,1 v3 !e3,2 f1 !e1,1 !e2,2!e3,2 v1 !e3,1 f2 !e4,1 !e1,2!e4,1 v3 !e4,2 f2 !e1,2 !e3,2!e4,2 v2 !e4,1 f1 !e2,1 !e1,1

The information stored in the doubly-connected edge list is enough to performthe basic operations. For example, we can walk around the outer boundaryof a given face f by following Next(!e) pointers, starting from the half-edgeOuterComponent( f ). We can also visit all edges incident to a vertex v. It is agood exercise to figure out for yourself how to do this.

We described a fairly general version of the doubly-connected edge list. Inapplications where the vertices carry no attribute information we could store32

MotivationDoubly-connected edge list

Map overlay

SubdivisionsRepresenting subdivisionsDCEL structure

The doubly-connected edge list

The doubly-connected edge listis a subdivision representationstructure with an object forevery vertex, every half-edge,and every face

A vertex object stores:

Coordinates

IncidentEdge (somehalf-edge leaving it)

A half-edge object stores:

Origin (vertex)

Twin (half-edge)

IncidentFace (face)

Next (half-edge in cycleof the incident face)

Prev (half-edge in cycleof the incident face)

Computational Geometry Lecture 2b: Subdivision representation and map overlay

,FU Berlin, Computational Geometry:, SS 2013 4

Page 6: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Doubly-connected edge list (DCEL)Motivation

Doubly-connected edge listMap overlay

SubdivisionsRepresenting subdivisionsDCEL structure

The doubly-connected edge list

A face object stores:

OuterComponent(half-edge of outer cycle)

InnerComponents (listof half-edges for the innercycles bounding the face)

f

Computational Geometry Lecture 2b: Subdivision representation and map overlay

,FU Berlin, Computational Geometry:, SS 2013 4

Page 7: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Polygon triangulation

Chapter 3POLYGON TRIANGULATION

3.1 Guarding and Triangulations

If we want to define the art gallery problem more precisely, we should firstformalize the notion of gallery. A gallery is, of course, a 3-dimensional space,but a floor plan gives us enough information to place the cameras. Therefore wemodel a gallery as a polygonal region in the plane. We further restrict ourselvesto regions that are simple polygons, that is, regions enclosed by a single closedpolygonal chain that does not intersect itself. Thus we do not allow regions withholes. A camera position in the gallery corresponds to a point in the polygon. Acamera sees those points in the polygon to which it can be connected with anopen segment that lies in the interior of the polygon.

How many cameras do we need to guard a simple polygon? This clearlydepends on the polygon at hand: the more complex the polygon, the morecameras are required. We shall therefore express the bound on the number ofcameras needed in terms of n, the number of vertices of the polygon. But evenwhen two polygons have the same number of vertices, one can be easier to guardthan the other. A convex polygon, for example, can always be guarded with onecamera. To be on the safe side we shall look at the worst-case scenario, that is,we shall give a bound that is good for any simple polygon with n vertices. (Itwould be nice if we could find the minimum number of cameras for the specificpolygon we are given, not just a worst-case bound. Unfortunately, the problemof finding the minimum number of cameras for a given polygon is NP-hard.)

Let P be a simple polygon with n vertices. Because P may be a complicatedshape, it seems difficult to say anything about the number of cameras we needto guard P. Hence, we first decompose P into pieces that are easy to guard,namely triangles. We do this by drawing diagonals between pairs of vertices.

Figure 3.2A simple polygon and a possible

triangulation of it

A diagonal is an open line segment that connects two vertices of P and lies inthe interior of P. A decomposition of a polygon into triangles by a maximalset of non-intersecting diagonals is called a triangulation of the polygon—seeFigure 3.2. (We require that the set of non-intersecting diagonals be maximal toensure that no triangle has a polygon vertex in the interior of one of its edges.This could happen if the polygon has three consecutive collinear vertices.)Triangulations are usually not unique; the polygon in Figure 3.2, for example,can be triangulated in many different ways. We can guard P by placing a camerain every triangle of a triangulation TP of P. But does a triangulation alwaysexist? And how many triangles can there be in a triangulation? The followingtheorem answers these questions.

46

A decomposition of a polygon into trianglesby a maximal set of non-intersecting diagonals

,FU Berlin, Computational Geometry:, SS 2013 5

Page 8: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Triangulating a simple polygon

Approach:

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Overview

A simple polygon is y-monotone iff anyhorizontal line intersects it in a connectedset (or not at all)

Use plane sweep to partition the polygoninto y-monotone polygons

Then triangulate each y-monotone polygon

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 6

Page 9: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Monotone polygons

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Monotone polygons

A y-monotone polygon has a top vertex, abottom vertex, and two y-monotone chainsbetween top and bottom as its boundary

Any simple polygon with one top vertexand one bottom vertex is y-monotone

Computational Geometry Lecture 4: Triangulating a polygonFormal proof ?

,FU Berlin, Computational Geometry:, SS 2013 7

Page 10: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Vertex types

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Vertex types

What types of vertices does a simplepolygon have?

start

stop

split

merge

regular

. . . imagining a sweep line going topto bottom

start

merge regular

split

end

Computational Geometry Lecture 4: Triangulating a polygonDefine type properties!

,FU Berlin, Computational Geometry:, SS 2013 8

Page 11: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Find diagonals from each mergevertex down, and from each splitvertex up

A simple polygon with no split ormerge vertices can have at most onestart and one end vertex, so it isy-monotone

Computational Geometry Lecture 4: Triangulating a polygonProof!

,FU Berlin, Computational Geometry:, SS 2013 9

Page 12: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

explored

unexplored

explored

unexplored

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 13: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the upper endpoint ofthe edge immediately left ofthe merge vertex?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 14: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the upper endpoint ofthe edge immediately left ofthe merge vertex?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 15: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the upper endpoint ofthe edge immediately left ofthe merge vertex?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 16: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the last vertex passedin the same “component”?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 17: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the last vertex passedin the same “component”?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 18: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Sweep ideas

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Sweep ideas

Where can a diagonal from asplit vertex go?

Perhaps the last vertex passedin the same “component”?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 10

Page 19: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Status of sweep

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Status of sweep

The status is the set of edgesintersecting the sweep line thathave the polygon to theirright, sorted from left to right,and each with their helper: thelast vertex passed in thatcomponent

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 11

Page 20: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Helpers of edges!

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Helpers of edges

The helper for an edge e thathas the polygon right of it,and a position of the sweepline, is the lowest vertex vabove the sweep line such thatthe horizontal line segmentconnecting e and v is insidethe polygon

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 12

Page 21: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Status structure, event list

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Status structure, event list

The status structure stores all edges that have the polygon tothe right, with their helper, sorted from left to right in theleaves of a balanced binary search tree

The events happen only at the vertices: sort them byy-coordinate and put them in a list (or array, or tree)

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 13

Page 22: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Main algorithm

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Main algorithm

Initialize the event list (all vertices sorted by decreasingy-coordinate) and the status structure (empty)

While there are still events in the event list, remove the first(topmost) one and handle it

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 14

Page 23: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Event handling

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Event handling

Start vertex v:

Insert the counterclockwiseincident edge in T with v as thehelper

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 15

Page 24: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Event handling

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Event handling

End vertex v:

Delete the clockwise incidentedge and its helper from T

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 15

Page 25: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Event handling

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Event handling

Regular vertex v:

If the polygon is right of the twoincident edges, then replace theupper edge by the lower edge inT , and make v the helper

If the polygon is left of the twoincident edges, then find theedge e directly left of v, andreplace its helper by v

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 15

Page 26: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Event handling

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Event handling

Merge vertex v:

Remove the edge clockwisefrom v from T

Find the edge e directly left ofv, and replace its helper by v

e

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 15

Page 27: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Event handling

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Event handling

Split vertex v:

Find the edge e directly left ofv, and choose as a diagonal theedge between its helper and v

Replace the helper of e by v

Insert the edge counterclockwisefrom v in T , with v as its helper

e

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 15

Page 28: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Efficiency

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Efficiency

Sorting all events by y-coordinate takes O(n log n) time

Every event takes O(log n) time, because it only involvesquerying, inserting and deleting in T

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 16

Page 29: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Representation

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Representation

A simple polygon with somediagonals is a subdivision ⇒use a DCEL

Question: How manydiagonals may be chosen tothe same vertex?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 17

Page 30: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

More sweeping

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

More sweeping

With an upward sweep in eachsubpolygon, we can find adiagonal down from everymerge vertex (which is a splitvertex for an upward sweep!)

This makes all subpolygonsy-monotone

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 18

Page 31: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

Result

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Result

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

Computational Geometry Lecture 4: Triangulating a polygonProof?

,FU Berlin, Computational Geometry:, SS 2013 19

Page 32: Computational Geometry: - Polygon triangulation · Computational Geometry: Polygon triangulation Panos Giannopoulos, Wolfgang Mulzer, Lena Schlipf AG TI SS 2013

This Friday:

MotivationTriangulating a polygon

Towards an efficient algorithmPartitioning into monotone piecesTriangulating a monotone polygonTriangulating a simple polygon

Triangulating a monotone polygon

How to triangulate ay-monotone polygon?

Computational Geometry Lecture 4: Triangulating a polygon

,FU Berlin, Computational Geometry:, SS 2013 20