Date post: | 11-Jan-2016 |
Category: |
Documents |
Upload: | jacob-hunter |
View: | 229 times |
Download: | 7 times |
AMS 345/CSE 355 AMS 345/CSE 355 Computational GeometryComputational Geometry
Triangulation AlgorithmsTriangulation Algorithms
Joe Mitchell
Some figures:
[O’Rourke]: Computational Geometry in C: Chap 2
Input: Set Input: Set SS of of nn points points
Input: Other shapesInput: Other shapes
3D: Surfaces and solids (tetrahedralization)3D: Surfaces and solids (tetrahedralization)
TriangulationTriangulation
22
Triangulation applet for simple polygons
Planar Straight-Line Graph (PSLG)Simple polygonPolygon with holes
Simple PolygonsSimple Polygons
DefinitionDefinition: A simple polygon P is the : A simple polygon P is the (closed) region bounded by a “simple (closed) region bounded by a “simple closed polygonal curve”.closed polygonal curve”.
Simple PolygonSimple Polygon Definition in [O’Rourke]:Definition in [O’Rourke]:
Simple PolygonsSimple Polygons
Alternate DefinitionAlternate Definition: P is a simple : P is a simple polygon if it is a simply connected polygon if it is a simply connected (i.e., no “holes”) subset of the plane (i.e., no “holes”) subset of the plane whose boundary consists of a whose boundary consists of a connected finite union of straight line connected finite union of straight line segments.segments.
Simple PolygonsSimple PolygonsSome definitions would allow this as a “degenerate” simple polygon
Definitions: Visibility, DiagonalsDefinitions: Visibility, Diagonals
For p,q in P, p is For p,q in P, p is visiblevisible to q if to q if segment pq lies within (closed) Psegment pq lies within (closed) P
pq
Definitions: Visibility, DiagonalsDefinitions: Visibility, Diagonals
For p,q in P, p is For p,q in P, p is visiblevisible to q if to q if segment pq lies within (closed) Psegment pq lies within (closed) P
p is p is clearly visibleclearly visible to q if p is visible to q if p is visible to q AND the only points in common to q AND the only points in common between pq and between pq and P are possibly p P are possibly p and qand q
p q
q’
p clearly sees q but does not clearly see q’ p sees q’
Definitions: Visibility, DiagonalsDefinitions: Visibility, Diagonals
vviivvjj is a is a diagonaldiagonal if v if vii and v and vjj are are vertices that clearly see each other vertices that clearly see each other (versus: (versus: chordchord pq, with p and q on pq, with p and q on the boundary of P)the boundary of P)
vi
vj
p
q
pq is a chord (not a diagonal)vivj is a diagonalvkvm is not a diagonal
vk
vm
DiagonalsDiagonals
[Devadoss-O’Rourke]
TriangulationTriangulation
Definition: A partition of P into Definition: A partition of P into triangles by a set of noncrossing triangles by a set of noncrossing diagonals. (= a partition of P by a diagonals. (= a partition of P by a maximalmaximal set of noncrossing set of noncrossing diagonals)diagonals)
[Devadoss-O’Rourke]
Triangulation Theory in 2DTriangulation Theory in 2D
Thm: A simple polygon Thm: A simple polygon hashas a triangulation. a triangulation.• Lem: An Lem: An nn-gon with -gon with nn44 has a diagonal. has a diagonal.
Thm: Any triangulation of a simple Thm: Any triangulation of a simple nn-gon has -gon has n-3n-3 diagonals, diagonals, n-2n-2 triangles. triangles.
Thm: The “dual” graph is a tree.Thm: The “dual” graph is a tree. Thm: An Thm: An nn-gon with -gon with nn4 has 4 has 2 “ears”.2 “ears”. Thm: The triangulation graph can be 3-colored.Thm: The triangulation graph can be 3-colored.
1212
Proofs: Induction on n.
Also with holes
But, NOT true in 3D!
EarsEars A diagonal of the form vA diagonal of the form vi-1i-1vvi+1i+1 is an is an
ear diagonalear diagonal; the triangle v; the triangle vi-1i-1vviivvi+1i+1 is is an an earear, and v, and vii is the is the ear tipear tip
Note that there are at most n ears Note that there are at most n ears (and that a convex polygon has (and that a convex polygon has exactly n ears)exactly n ears)
vi-1vi+1
vi
EarsEars
Proof(1): There are n edges of P and n-2 triangles in any triangulation. Imagine dropping the n edges into the n-2 “pigeonholes” corresponding to the triangles: Each edge appears on boundary of some triangle. By pigeonhole principle, at least 2 triangles get 2 edges “dropped in their box”.
(2) Consider the planar dual (excluding the face at infinity) of a triangulation of P. Claim: The dual graph for a triangulated simple polygon is a TREE. Any tree of 2 or more nodes has at least 2 nodes of degree 1.
[Devadoss-O’Rourke]
Triangulating a Simple PolygonTriangulating a Simple Polygon Simple “ear-clipping” methods: O(Simple “ear-clipping” methods: O(nn2 2 )) Cases with simple O(Cases with simple O(nn) algorithms:) algorithms:
• Convex polygons (trivial!)Convex polygons (trivial!)• Monotone polygons, monotone mountainsMonotone polygons, monotone mountains
General case (even with holes!):General case (even with holes!):• Sweep algorithm to decompose into Sweep algorithm to decompose into
monotone mountainsmonotone mountains• O(O(n log nn log n))
Best theoretical results:Best theoretical results:• Simple polygons: O(Simple polygons: O(nn) [Chazelle’90]) [Chazelle’90]• Polygons with Polygons with hh holes: O( holes: O(n+h logn+h log1+1+ hh), ), ((n+h log hn+h log h) [BC]) [BC]
Good practical method: FIST [Held], based on clever Good practical method: FIST [Held], based on clever methods of ear clipping (worst-case O(methods of ear clipping (worst-case O(nn2 2 ) )) )
1616
Not practical!
fan
Lower Bound Lower Bound ((n+h log hn+h log h) )
((nn) : Have to read the data) : Have to read the data ((h log hh log h) : from SORTING) : from SORTING
1717
FIST: Fast Industrial-Strength TriangulationFIST: Fast Industrial-Strength Triangulation
http://www.cosy.sbg.ac.at/~held/projects/triang/triang.html
Constrained Delaunay
Simple polygon FIST
Works nicely also for highly degenerate and “crazy” polygons
3D cycles
Based on ear clipping
Ear-Clipping TriangulationEar-Clipping Triangulation
Ear-clipping applet
Input: Simple polygon P
vi-1vi+1
pq is a diagonal, cutting off a single triangle (the “ear”)
Naive: O(n3) Smarter: Keep track of “ear tip status” of each vi (initialize: O(n2) )Each ear clip requires O(1) ear tip tests ( @ O(n) per test )Thus, O(n2) total, worst-case
vi
TriangulateTriangulate
Ear-ClippingEar-Clipping
Lemma: When clipping ear wth tip Lemma: When clipping ear wth tip vvii the only ear tip statuses that can the only ear tip statuses that can change are at change are at vvi-1i-1 andand v vi+1i+1
Example: TriangulateExample: Triangulate
Example: OutputExample: Output
(n(n22 ) Examples Exist ) Examples Exist
Today, 9/26/13Today, 9/26/13
Review: O(n log n) triangulationReview: O(n log n) triangulation ExamplesExamples Primitives: Left test, etcPrimitives: Left test, etc Time permitting: Convex Time permitting: Convex
decompositions, Hertel-Mehlhorndecompositions, Hertel-Mehlhorn
Faster Algorithm: O(n log n)Faster Algorithm: O(n log n)
Input: PSLG of size n; enclosed by a big box BInput: PSLG of size n; enclosed by a big box B Step 1: Use sweep to decompose B into “y-Step 1: Use sweep to decompose B into “y-
monotone mountains” – y-monotone monotone mountains” – y-monotone polygons having one side (left/right) a single polygons having one side (left/right) a single segment (the “base”); O(n log n)segment (the “base”); O(n log n)
Step 2: Triangulate each y-monotone polygon Step 2: Triangulate each y-monotone polygon (size n(size ni i ) in time O(n) in time O(nii), for total O(n)), for total O(n)
Overall: O(n log n) to triangulate PSLGOverall: O(n log n) to triangulate PSLG
2828
Monotone PolygonsMonotone Polygons
P is monotone in direction dP is monotone in direction d
d
b
t
Every line perpendicular to d intersects P in a connected set; i.e., the left/right chains from bottom, b, to top, t, are each d-monotone.
Monotone PolygonsMonotone Polygons
P is monotone in direction dP is monotone in direction d
d
y-Monotone Polygony-Monotone Polygon
d
ExamplesExamples
Which of these polygons are Which of these polygons are monotone? (with respect to which monotone? (with respect to which directions d?)directions d?)
Which are monotone mountains? Which are monotone mountains? With respect to which directions d?With respect to which directions d?
ExamplesExamplesCircle of directions of monotonicity, d
Example from Practice MidtermExample from Practice Midterm
y-Monotone Polygony-Monotone Polygon
d
Monotone MountainsMonotone Mountains
d
b
t
Ear clipping is easy!Ear clipping is easy!• Testing if Testing if vvi-1i-1 v vi+1 i+1 is a diagonal takes only is a diagonal takes only
O(1) timeO(1) time
Triangulating a Monotone Triangulating a Monotone Mountain in O(Mountain in O(nn))
3737
vi-1
vi+1
vi
monotone
Just traverse vertices from top to bottom. Test/clip ears. If an ear is clipped, re-test the earity of the upper endpoint (vi-1 ) of the diagonal just clipped.
vi is ear tip iff Left(vi+1 , vi , vi-1 )
t
b
Triangulating a Monotone Triangulating a Monotone Mountain in O(Mountain in O(nn))
3838
ExampleExample
3939
Triangulation in O(Triangulation in O(n log nn log n))
(1) Plane sweep to get horizontal trapezoidalization(1) Plane sweep to get horizontal trapezoidalization
4040
L
SLS: left-to-right ordering of segments crossed by L (balanced binary tree)Events: L hits a vertex Time: O(n log n)
Fire bullets left/right from each vertex
Sweep AlgorithmsSweep Algorithms
Paradigm: Process geometric data by Paradigm: Process geometric data by “sweeping” over it, in some order“sweeping” over it, in some order
Sweep AlgorithmsSweep Algorithms Two key ingredients of any sweep algorithm:Two key ingredients of any sweep algorithm:
• (1) The “Sweep Line Status” (SLS): gives a (1) The “Sweep Line Status” (SLS): gives a “combinatorial description” of the “slice” given by “combinatorial description” of the “slice” given by the sweeping linethe sweeping line
Often stored in a balanced binary treeOften stored in a balanced binary tree
• (2) Events: These are instants when the SLS (2) Events: These are instants when the SLS “changes” combinatorially, and we must pause and “changes” combinatorially, and we must pause and do some event handling. Store in “Event Queue” do some event handling. Store in “Event Queue” (EQ), often a “priority queue” that allows us to (EQ), often a “priority queue” that allows us to quickly determine the next eventquickly determine the next event
Often events occur at certain discrete points/vertices of the Often events occur at certain discrete points/vertices of the input; EQ is sometimes “static” (events known in advance), input; EQ is sometimes “static” (events known in advance), sometimes “dynamic” (events learned as we go)sometimes “dynamic” (events learned as we go)
Sweep AlgorithmsSweep Algorithms
What is needed to describe a sweep What is needed to describe a sweep algorithm:algorithm:• What is being “swept”? (line, plane, curve, etc) What is being “swept”? (line, plane, curve, etc)
And how is it “sweeping”? (“order”?)And how is it “sweeping”? (“order”?)• What exactly does the SLS store, and in what kind What exactly does the SLS store, and in what kind
of data structure is it stored (to provide for of data structure is it stored (to provide for efficient updates as it changes)?efficient updates as it changes)?
• Exactly what are the “events”? How are they Exactly what are the “events”? How are they stored (the Event Queue, EQ)? How are they stored (the Event Queue, EQ)? How are they handled? Usually there are various cases, and one handled? Usually there are various cases, and one must specify for each exactly what updates are must specify for each exactly what updates are made to the SLS and the EQ (if any).made to the SLS and the EQ (if any).
TrapezoidalizationTrapezoidalization
TrapezoidalizationTrapezoidalization
TrapezoidalizationTrapezoidalization
In each case: We do O(1) updates to the SLS, each taking time O(log n), since the SLS is stored in a balanced binary search tree.
TrapezoidalizationTrapezoidalization
Triangulation in O(Triangulation in O(n log nn log n))
(2) Join top vertex to bottom vertex in each trapezoid(2) Join top vertex to bottom vertex in each trapezoid
4848Lemma: Resulting pieces are monotone mountains
Triangulation in O(Triangulation in O(n log nn log n)) (3) Triangulate each monotone mountain(3) Triangulate each monotone mountain
4949
Triangulate each, in time O(ni ), for total time O(n)
Summary: O(n log n) to triangulate n points or a planar straight-line graph (PSLG)
Bottom Line: Triangulation in 2DBottom Line: Triangulation in 2D
Best theoretical results:Best theoretical results:• Simple polygons: O(Simple polygons: O(nn) [Chazelle’90]) [Chazelle’90]• Polygons with Polygons with hh holes: O( holes: O(n+h logn+h log1+1+ hh), ),
((n+h log hn+h log h) [BC]) [BC]• PSLG: for each simple face (without PSLG: for each simple face (without
holes), O(holes), O(nnii); for each face with holes, ); for each face with holes, O(O(nnii+h+hii log log1+1+ hhii) )
Good practical method: FIST [Held], based Good practical method: FIST [Held], based on clever methods of ear clipping (worst-on clever methods of ear clipping (worst-case O(case O(nn2 2 )) ))
Convex DecompositionConvex Decomposition
Partition simple polygon P into a Partition simple polygon P into a small number of convex piecessmall number of convex pieces
One way to do it: Triangulate P
Convex DecompositionConvex Decomposition
Partition simple polygon P into a Partition simple polygon P into a small number of convex piecessmall number of convex pieces
Another way to do it: Use diagonals to partition P into convex polygons
Convex DecompositionConvex Decomposition
Partition simple polygon P into a Partition simple polygon P into a small number of convex piecessmall number of convex pieces
Another way to do it: Allow “Steiner” points (non-vertices) inside P.May get fewer pieces!
Convex DecompositionConvex Decomposition
Goal: Partition P into a small number of convex Goal: Partition P into a small number of convex pieces (convex polygons)pieces (convex polygons)
A triangulation is one possible decomposition into A triangulation is one possible decomposition into convex pieces, but it may have many more pieces convex pieces, but it may have many more pieces than necessary!than necessary!
Dynamic Programming algorithms yield optimal Dynamic Programming algorithms yield optimal solutions for simple polygons (for both Steiner and solutions for simple polygons (for both Steiner and non-Steiner versions), in roughly O(nnon-Steiner versions), in roughly O(n33))
Hertel-Mehlhorn algorithm: 4-approximation in time Hertel-Mehlhorn algorithm: 4-approximation in time O(n)O(n)
5454
O(r2n log n) without Steiner [Keil’85]; O(n+r3) allowing Steiner [Chazelle’80]
Convex DecompositionConvex Decomposition
5555
Convex DecompositionConvex Decomposition
5656
Optimal Convex DecompositionOptimal Convex Decomposition
5757
Allowing Steiner pointsAllowing Steiner points
Convex DecompositionConvex Decomposition
5858
r=6
Convex DecompositionConvex Decomposition
5959
r=6
One diagonal “resolves” the local nonconvexities at 2 reflex vertices at once
We need at least r/2 segments to resolve all r reflex vertices Results in at least
ceil(r/2)+1 pieces
Hertel-Mehlhorn AlgorithmHertel-Mehlhorn Algorithm
6060
Start with any triangulation of simple Start with any triangulation of simple polygon P (time O(n), [Chazelle])polygon P (time O(n), [Chazelle])
Remove inessential diagonals, in any Remove inessential diagonals, in any order (order (time O(n), since we can test a time O(n), since we can test a diagonal locally in time O(1) to see if it is diagonal locally in time O(1) to see if it is essential; if we remove a diagonal, we essential; if we remove a diagonal, we only have to update the “inessential” flag only have to update the “inessential” flag of O(1) other diagonalsof O(1) other diagonals))
Hertel-Mehlhorn AlgorithmHertel-Mehlhorn Algorithm
6161
Lemma 2.5.2: At the end of the Lemma 2.5.2: At the end of the algorithm, for each reflex vertex v, algorithm, for each reflex vertex v, there can be at most 2 diagonals there can be at most 2 diagonals essential for vessential for v
Hertel-Mehlhorn AlgorithmHertel-Mehlhorn Algorithm
6262
Theorem 2.5.3Theorem 2.5.3: The H-M algorithm : The H-M algorithm yields a decomposition into at most yields a decomposition into at most 4*OPT pieces, where OPT is the 4*OPT pieces, where OPT is the minimum possible number of convex minimum possible number of convex pieces in a (Steiner) convex pieces in a (Steiner) convex decomposition.decomposition.
We say that the H-M Algorithm is a “4-approximation algorithm”
OPEN: Find a better factor than 4, which still runs very efficiently (say, in O(n log n) or O(n) time).
Hertel-Mehlhorn AlgorithmHertel-Mehlhorn Algorithm
6363
ProofProof: At end, each diagonal is : At end, each diagonal is essential for some (reflex) vertex.essential for some (reflex) vertex.
By Lemma 2.5.2, there are at most By Lemma 2.5.2, there are at most 2r diagonals left (2r diagonals left (since each reflex vertex is since each reflex vertex is
“responsible” for at most 2 diagonals“responsible” for at most 2 diagonals)) Thus, the number, M, of pieces is ≤ Thus, the number, M, of pieces is ≤
2r+1 < 2r+4 ≤ 4*OPT2r+1 < 2r+4 ≤ 4*OPT(Since, by Theorem 2.5.1, OPT ≥ ceil(r/2)+1, so (Since, by Theorem 2.5.1, OPT ≥ ceil(r/2)+1, so
4*OPT ≥4*ceil(r/2)+4≥2r+4)4*OPT ≥4*ceil(r/2)+4≥2r+4)
H-M Algorithm: ExampleH-M Algorithm: Example
Minimum-Weight TriangulationMinimum-Weight Triangulation
MWT of a simple polygon: O(nMWT of a simple polygon: O(n33), using ), using dynamic programmingdynamic programming
MWT of a polygon with holes (or of a MWT of a polygon with holes (or of a set of points in the plane) is NP-hardset of points in the plane) is NP-hard
Min-Weight Steiner Triangulation: Min-Weight Steiner Triangulation: allow extra “Steiner” points to be allow extra “Steiner” points to be addedadded• Not known to Not known to existexist• 316-approximation known316-approximation known
6565
AMS 545 / CSE 555
MWT in Simple PolygonMWT in Simple Polygon
Dynamic ProgrammingDynamic Programming Bellman equation:Bellman equation:
• Let f(i,j) be the total length of diagonals Let f(i,j) be the total length of diagonals in a min-weight triangulation in the in a min-weight triangulation in the simple polygon left of diagonal (i,j).simple polygon left of diagonal (i,j).
f(i,j) = 0, if (i,j) is ear diagonal; else,f(i,j) = 0, if (i,j) is ear diagonal; else,
f(i,j)=minf(i,j)=mink:k sees i,j k:k sees i,j [|ik|+|kj|+f(i,k)+f(k,j)] [|ik|+|kj|+f(i,k)+f(k,j)]
i
j
k
Time O(n3)
AMS 545 / CSE 555
Related Optimizations Using DPRelated Optimizations Using DP
Min-max diagonal triangulation of PMin-max diagonal triangulation of P Max-min diagonal Max-min diagonal Min-max area triangleMin-max area triangle Max-min area triangleMax-min area triangle Max-min angle Max-min angle Min-max angleMin-max angle Fewest-guards-by-Fisk-methodFewest-guards-by-Fisk-method etcetc
AMS 545 / CSE 555