triangulation2
triangulation2
Spring 2015
Triangulations and
Guarding Art Galleries II
Carola Wenk
x-monotone
(monotone
w.r.t l)
l
2/3/15 CMPS 3130/6130 Computational Geometry 3
Monotone Polygons
• A simple polygon P is called monotone with respect to a
line l iff for every line l’ perpendicular to l the intersection of
P with l’ is connected.
– P is x-monotone iff l = x-axis
– P is y-monotone iff l = y-axis l’
NOT x-monotone
(NOT monotone
w.r.t l)
l
2/3/15 CMPS 3130/6130 Computational Geometry 4
Monotone Polygons
• A simple polygon P is called monotone with respect to a
line l iff for every line l’ perpendicular to l the intersection of
P with l’ is connected.
– P is x-monotone iff l = x-axis
– P is y-monotone iff l = y-axis
l’
l
2/3/15 CMPS 3130/6130 Computational Geometry 5
Test Monotonicity
How to test if a polygon is x-monotone?
– Find leftmost and rightmost vertices, O(n) time
→ Splits polygon boundary in upper chain and lower chain
– Walk from left to right along each chain, checking that x-
coordinates are non-decreasing. O(n) time.
2 10
4 5
3 9
1 8
6
13
l
2/3/15 CMPS 3130/6130 Computational Geometry 8
Triangulate an l-Monotone Polygon
• Store stack (sweep line status) that contains vertices that have
been encountered but may need more diagonals.
• Maintain invariant: Un-triangulated region
has a funnel shape. The funnel consists of an
upper and a lower chain. One chain is one line
segment. The other is a reflex chain (interior
angles >180°) which is stored on the stack.
• Update, case 1: new vertex lies on chain
opposite of reflex chain. Triangulate.
v
u split vertex v
u = helper(e)
e’
2/3/15 CMPS 3130/6130 Computational Geometry 14
Sweep Line Algorithm
• Events: Vertices of polygon, sorted in increasing order by
x-coordinate. (No new events will be added)
• Sweep line status: Balanced binary search tree storing the
list of edges intersecting sweep line, sorted by y-coordinate.
Also, helper(e) for every edge intersecting sweep line.
• Event processing of vertex v:
e
1. Split vertex:
– Find edge e lying immediately above v.
– Add diagonal connecting v to helper(e). v
– Add two edges incident to v to sweep line status.
– Make v helper of e and of the lower of the two edges