CG Lecture 3 Motivation: Art gallery problem Definition: two points q and r in a Polygon decomposition simple polygon P can see each other if the open segment qr R lies entirely within P. 1. Polygon triangulation p q • Triangulation theory A point p guards a region • Monotone polygon triangulation R ⊆ P if p sees all q∈R 2. Polygon decomposition into monotone r pieces Problem: Given a polygon P, what 3. Trapezoidal decomposition is the minimum number of guards 4. Convex decomposition required to guard P, and what are their locations? 5. Other results 1 2 Simple observations Art gallery problem: upper bound • Convex polygon: all points • Theorem: Every simple planar are visible from all other polygon with n vertices has a points only one guard in triangulation of size n-2 (proof any location is necessary! later). convex • Star-shaped polygon: all • n-2 guards suffice for an n-gon: points are visible from any • Subdivide the polygon into n–2 point in the kernel only triangles (triangulation). one guard located in its • Place one guard in each triangle. kernel is necessary. star-shaped 3 4 Art gallery problem: lower bound Simple polygon triangulation • There exists a Input: a polygon P polygon with n described by an ordered vertices, for which sequence of vertices ⎣n/3⎦ guards are <v0, …vn–1>. necessary. Output: a partition of P Can we improve the upper into n–2 non-overlapping • Therefore, ⎣n/3⎦ bound? triangles and the guards are needed in adjacencies between Yes! In fact, at most ⎣n/3⎦ the worst case. guards are necessary. them. 5 6 1 Simple polygon triangulation: observations Ideas? • The triangulation is not unique. One of them suffices. • The triangulation is always possible. • No new vertices are required. • The triangulation adds new edges, called diagonals, between existing vertices. Not all diagonals are valid! 7 8 Triangulation theory Diagonals in polygons • A vertex is convex if its interior angle < π, Proof: let v be a convex vertex and let Case 1 otherwise it is concave. a and b its adjacent vertices. Since P a •A diagonal is a new edge between two polygon is a simple polygon and n>3, there is vertices that is entirely inside the polygon. no edge between a and b. b • Lemma 1: every polygon has a convex vertex. Consider the following two cases: v Proof: the highest vertex (the one with the 1. the new edge ab is a diagonal Case 2 largest y coordinate) is convex. 2. Otherwise, there exists a vertex x L a x which is the closest to v with • Lemma 2: Every polygon with n>3 vertices has b respect to a line L parallel to ab a diagonal. v which is a diagonal. 9 10 Triangulation theory Triangulation dual Theorem: Every simple polygon with Definition: The triangulation dual T n vertices has a triangulation with of a triangulation of a simple P n–3 diagonals and n–2 triangles. 1 polygon P is a graph whose nodes are triangles and whose edges are Proof: By induction on n: adjacencies between triangles • Basis: A triangle (n=3) has a sharing an edge. triangulation (itself) with no v Property: the triangulation dual is a diagonals and one triangle. P2 tree whose node degree is ≤ 3. • Induction on n: Proof: For an n-vertex polygon, construct a diagonal dividing the polygon • Degree ≤ 3 by construction: no triangle has more than into two polygons P1 and P2 with n1 and n2 vertices such that three neighbors. n1+n2–2 = n. • No cycles: by contradiction. If it has a cycle, it is a Diagonals: (n1–3)+(n2 –3)+1 = (n1+n2–2)–3 = n–3 polygon with a hole (not a simple polygon). Triangles: (n –2)+(n –2) = (n +n –2)–2 = n–2 11 12 1 2 1 2 • If fact, T is a binary tree with root degree one or two! 2 Simple triangulation algorithm (1) Simple triangulation algorithm Idea: Reduce the polygon by clipping a proc triangulate(P) v1 v2 triangle at each iteration. if |P| ≤ 3 output(P) and return; i 0; The clipped triangle will be formed by while diagonal(v ,v ) is not legal i++; v0 three consecutive vertices i i+2 output(vi,vi+1,vi+2); (vi,vi+1,vi+2). The diagonal is (vi,vi+2). remove vi+1 from P; triangulate(P); Test for validity: 1. The diagonal does not intersect other Complexity: n times n diagonal tests that take polygon edges. each O(n) O(n3). 2. The diagonal must be inside the Sources of inefficiencies: polygon (test that diagonal is inside • repeated diagonal tests normal cone). • diagonals are not sorted or ordered 2 13 Precompute diagonals in O(n ). 14 Triangulation algorithms O(n log n)-time triangulation algorithm • What is the lower bound? 1) Partition the polygon 2 • O(n ) by precomputing diagonals into y-monotone pieces • Improve to O(nlogn) by ordering them (see later). .(”חתיכות מונוט וניות“) • Is less than O(nlogn) possible? 2) Triangulate each y-monotone piece separately. 15 17 Monotone polygons: definition Property of monotone polygons • A simple polygon is called L Definition: a vertex v is an interior cusp iff it is a concave monotone with respect to a line L if L vertex whose adjacent vertices are both at or above (at for any line L’ perpendicular to L or below) line L. the intersection of the polygon with v L’ is connected. L • A polygon is called monotone if v there exists any such line ℓ. Theorem: If a polygon P has no interior cusps with • A polygon that is monotone with respect to a line L, then it is monotone with respect to L. respect to the x/y-axis is called x/y- Proof sketch: partition P into two chains connecting the monotone. top and bottom vertices. Assume one of them is not monotone with respect to L. Then P must contain an Question: How can we check in O(n) y-monotone but not x-monotone polygon interior cusp above or below. time whether a polygon is y-monotone? 18 19 3 Triangulating a y-monotone polygon Triangulating a Y-monotone polygon • Sweep the polygon from top to bottom. • Continue sweeping while one chain contains only one edge, left chain right chain • Greedily triangulate anything possible above the while the other edge is concave. top sweep line, and then forget about this region. • When a “convex edge” appears • When procesing a vertex v, the unhandled region above it always has a simple structure: in the concave chain (or a Two y-monotone (left and right) chains, each second edge appears in the other containing at least one edge. If a chain consists of two one), triangulate as much as or more edges, it is reflex, and the other chain consists possible using a “fan”. of a single edge whose bottom endpoint has not been • Time complexity: O(k), where k handled yet. is the complexity of the polygon. bottom • Each diagonal is added in O(1) time. 20 21 Stack operations on chains Monotone polygon triangulation 22 23 Y-monotone polygons Vertex classification Polygon vertices classification: •A start (resp., end) vertex is a start vertex whose interior angle is less than π and its two neighboring vertices both lie merge below (resp., above) it. regular •A split (resp., merge) vertex is a vertex whose interior angle is split greater than π and its two neighboring vertices both lie end below (resp., above) it. • All other vertices are regular. 24 25 4 Y-monotone polygons: properties Split and merge vertices Theorem: A polygon without split start and merge vertices is y-monotone. Proof: Since there are only merge start/end/regular vertices, the regular polygon must consist of two y-monotone chains. split Alternatively, do a case analysis. • To partition a polygon to monotone pieces, end eliminate split (merge) vertices by adding diagonals upward (downward) from the vertex. Naturally, the diagonals must not intersect! 26 27 Monotone partitioning Monotone partitioning (cont.) • Classify all vertices. • A split vertex may be connected e helper(e ) k • Sweep the polygon from top to bottom. j to the helper vertex of the edge e • Maintain the edges intersected by the j immediately to its left. v sweep line L sorted by x coordinate). i helper(e ) j • However, a merge vertex should e • Maintain vertex events in an event queue i e vi e Q sorted by y coordinate. j k be connected to a vertex which e has not been processed yet! • Eliminate split/merge vertices by ei-1 i connecting them to other vertices. • Clever idea: Every merge vertex vi is the helper of some edge, and helper(e ) ek • For each edge e, define helper(e) as the ej j will be handled when this edge lowest vertex (seen so far) above the vm sweep line visible to the right of the edge. “terminates”. • helper(e) is initialized by the upper endpoint of e. 28 29 Monotone partitioning algorithm Monotone partitioning Input: A counterclockwise ordered list of vertices. The edge ei immediately follows the vertex vi. Handling a start vertex vi: Construct Q on the vertices of P using y-coordinates. v •Addei to L 1 v8 (when two or more vertices have the same y-coordinates, e9 • helper(ei) vi v e1 the vertex with the smaller x-coordinate has priority.) 3 e8 e e v9 7 • Initialize L to be empty. 2 e3 v2 v •While Q is not empty: 7 v5 •Pop vertex v; v4 e4 e e 6 • Handle v.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-