Ch.3 Art Gallery Problem & Triangulating Polygons
Ch.3 Art Gallery Problem & Triangulating Polygons
!
paintings
Assumptions/Definitions
!Floor
Assumptions/Definitions
!Number
!Let
!Def
-- triangulation #1
-- triangulation #2
triangulations generally
not unique
So what ?
Can we guard a polygon by placing a camera in every
triangle? (actually overkill, but well come back to this later)
Questions :
1.
2.
Theorem 3.1
Every simple polygon has a triangulations. Every triangulation
of an n-vertex simple polygon has exactly n-2 triangles.
Proof
By induction on n, number of vertices of polygon P.
basis : n=3 P is a triangle and n-2 = 3-2 = 1
inductive hypothesis : every polygon with n < n vertices
has a triangulation with exactly n-2 triangles.
inductive step :
Let P be a polygon with n vertices
We
this will break P into two subpolygons, each with <n vertices
let v be leftmost vertes in P (lowest if tie) and let u & w be
vertices adjecent to v on Ps boundary
Case 1 open segment uw lies in interior of P ( & is a diagonal )
uw is a diagonal
n = 11
m1 = 7
m2 = 6
We want a 3-coloring of Tp
That is, a coloring of Tp with 3 colors.
every triangle will have a red,blue & green vertex
place cameras at, say, every red vertex (all triangles
visible) choose smallest color class & well need at most
n/3 cameras
Does a 3-coloring of Tp always exist ?
YES
Consider dual graph of Tp, G(Tp)
-- has vertex for every Tp ( v = node
in G(Tp), (v) = in Tp
-- edge (v,w) G(Tp) (v) & (w) share
diagonal in Tp
( so, every edge in G(Tp) corresponds to
diagonals in Tp )
!Can
So,
!Possible
!Unfortunately,
DEF:
Y-monotone: A simple polygon, P, is y-monotone if the intersection
of P with any horizontal line is connected (i.e. a point, a segment,
or ).
(P is strictly y-monotone if it has no horizontal edges.)
FACT:
Let P be y-monotone,
and let v & w be top and
bottom vertices. If we
move on left (or right)
boundary chain of P
from v to w, then we
always move down or
horizontally (never up).
y-monotone
Not y-monotone
3
4
5
Funnel
Partial Edge
Reflex Chain
7
boundary is chain of
reflex vertices (interior angles
at least 180) except for lowest
vertex (top of stack).
!Other
boundary is (partial)
edge. (We have not seen
bottom endpoint yet).
8
9
10
11
12
Last encountered
Vertex
3
4
Vl
5
6
7
8
Vj
10
11
12
Vk
each vertex in turn until finding one that does not make a diagonal
Popped and
pushed
popped
Popped and
pushed
Vj
pushed
pushed
Vj
Note: Checking if each diagonal can be drawn from Vj to Vk on the stack can be done by looking at Vj,
Vk and previously popped vertex.
u1
u2
u2
u3
u4
u5
u3
u4
u5
u6
u7
u8
u9
u6
u7
u8
u9
u4
u5
u2
u6
u7
u8
u9
u1
u4
u5
u6
u7
u8
u4
u3
u9
else
!
!
!
u1
u2
u3
u4
u5
u6
u7
u8
u6
u4
u9
u1
u2
u3
u4
u5
u6
u7
u8
u9
Theorem
A strictly monotone polygon can be triangulated in linear time
Non-strict Monotonicity
The algorithm still works if two vertices have the same ycoordinate; they may be processed in increasing order of their xcoordinates
!
!
Merge Vertex
Both neighbors are above it
Interior angle > 1800
Need to add diagonals down
Split Vertex
Both neighbors are below it
Interior angle > 1800
Need to add diagonals up
Lemma
A polygon P is y-monotone if and only if it has no split or merge
vertices
Proof
Sweepline Algorithm
!
!
!
Definition
!
Sweepline Status
Helper(ej)
ej
vi
ei-1
ei
Helper(ej)
ej
vi
ei-1
ei
Helper(ej)
ej
vi
ei-1
ei
helper(ej)
Vi+1
Vi-1
ei
ej
(merge vertex)
vi
helper(ei-1)
(merge vertex)
New helper (ej)
helper(ej)
Vi+1
Vi-1
ei
ej
(merge vertex)
vi
helper(ei-1)
(merge
vertex)
helper(ej)
Vi+1
Vi-1
ei
ej
(merge vertex)
vi
helper(ei-1)
(merge
vertex)
helper(ej)
Vi+1
Vi-1
ei
ej
(merge vertex)
vi
new helper(ej)
helper(ei-1)
(merge
vertex)
General Strategy
!
!
Regular vertex vi
!
End vertex ve
regular vertex
end vertex
vi
Start vertex
!First
event point
!Highest vertex
ei in T
!Set helper (ei)=vi
ei
ei-1
End vertex
!Last
event
!Lowest vertex
helper(ei-1)
ei
ei-1
vi
Handle end vertex (ve=vi)
!If
helper(ei-1)
ei-1
vi
ei
helper(ej)
ei
ej
vi
ei-1
vm
ej
vi
Running Time
1.
2.
Total: O(nlogn)
Storage O(n)
Theorem 3.6
A simple polygon with n vertices can be partitioned into ymonotone polygones in O(nlogn) time using O(n) storage
2.
O(nlogn)