24: Polygon Partition - Faster Triangulations

Similar documents
Triangulation by Ear Clipping

Shortest Inspection-Path. Queries in Simple Polygons

Computational Geometry. Lecture 1: Introduction and Convex Hulls

Shortest Path Algorithms

Arrangements And Duality

Line Segment Intersection

Computational Geometry: Line segment intersection

Approximation of an Open Polygonal Curve with a Minimum Number of Circular Arcs and Biarcs

Persistent Data Structures and Planar Point Location

INTERSECTION OF LINE-SEGMENTS

Shortcut sets for plane Euclidean networks (Extended abstract) 1

Connectivity and cuts

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

39 Symmetry of Plane Figures

Disjoint Compatible Geometric Matchings

Mathematical Induction. Mary Barnes Sue Gordon

1. A student followed the given steps below to complete a construction. Which type of construction is best represented by the steps given above?

BALTIC OLYMPIAD IN INFORMATICS Stockholm, April 18-22, 2009 Page 1 of?? ENG rectangle. Rectangle

Lesson 2: Circles, Chords, Diameters, and Their Relationships

Selected practice exam solutions (part 5, item 2) (MAT 360)

Linear Programming I

Chapter 3.1 Angles. Geometry. Objectives: Define what an angle is. Define the parts of an angle.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

SHARP BOUNDS FOR THE SUM OF THE SQUARES OF THE DEGREES OF A GRAPH

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

5.1 Bipartite Matching

Largest Fixed-Aspect, Axis-Aligned Rectangle

Data Structures Fibonacci Heaps, Amortized Analysis

Definitions, Postulates and Theorems

arxiv: v1 [math.co] 7 Mar 2012

Binary Heap Algorithms

Closest Pair Problem

HOLES 5.1. INTRODUCTION

Heaps & Priority Queues in the C++ STL 2-3 Trees

Point Location. Preprocess a planar, polygonal subdivision for point location queries. p = (18, 11)

Which shapes make floor tilings?

Solving Geometric Problems with the Rotating Calipers *

The minimum number of distinct areas of triangles determined by a set of n points in the plane

The Triangle and its Properties

Triangle deletion. Ernie Croot. February 3, 2010

Diffuse Reflection Radius in a Simple Polygon

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

INCIDENCE-BETWEENNESS GEOMETRY

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

11.3 Curves, Polygons and Symmetry

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

Graph Theory Problems and Solutions

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

Angles that are between parallel lines, but on opposite sides of a transversal.

Lecture 22: November 10

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

Fast approximation of the maximum area convex. subset for star-shaped polygons

Geometry 8-1 Angles of Polygons

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

5.1 Midsegment Theorem and Coordinate Proof

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

6 March Array Implementation of Binary Trees

Area. Area Overview. Define: Area:

Chapter 6 Notes: Circles

Geometry 1. Unit 3: Perpendicular and Parallel Lines

8.1 Min Degree Spanning Tree

Distributed Computing over Communication Networks: Maximal Independent Set

Lecture 3: Derivatives and extremes of functions

Angle - a figure formed by two rays or two line segments with a common endpoint called the vertex of the angle; angles are measured in degrees

Topological Treatment of Platonic, Archimedean, and Related Polyhedra

Chapters 6 and 7 Notes: Circles, Locus and Concurrence

Persistent Data Structures

PYTHAGOREAN TRIPLES KEITH CONRAD

Solutions to Homework 6

Finding and counting given length cycles

G5 definition s. G1 Little devils. G3 false proofs. G2 sketches. G1 Little devils. G3 definition s. G5 examples and counters

Parallel and Perpendicular. We show a small box in one of the angles to show that the lines are perpendicular.

Binary Search Trees CMPSC 122

SPERNER S LEMMA AND BROUWER S FIXED POINT THEOREM

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

Removing Local Extrema from Imprecise Terrains

EdExcel Decision Mathematics 1

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

ONLINE DEGREE-BOUNDED STEINER NETWORK DESIGN. Sina Dehghani Saeed Seddighin Ali Shafahi Fall 2015

DEFINITIONS. Perpendicular Two lines are called perpendicular if they form a right angle.

Most popular response to

GEOMETRY. Constructions OBJECTIVE #: G.CO.12

Analysis of Binary Search algorithm and Selection Sort algorithm

4. How many integers between 2004 and 4002 are perfect squares?

alternate interior angles

Conjectures. Chapter 2. Chapter 3

Mathematics Geometry Unit 1 (SAMPLE)

Pro/ENGINEER Wildfire 5.0 Introduction to Surface Modeling

Constrained Tetrahedral Mesh Generation of Human Organs on Segmented Volume *

Scheduling Shop Scheduling. Tim Nieberg

Transcription:

24: Polygon Partition - Faster Triangulations CS 473u - Algorithms - Spring 2005 April 15, 2005 1 Previous lecture We described triangulations of simple polygons. See Figure 1 for an example of a polygon and its triangulation. We also described a quadratic time algorithm to compute a triangulation. 2 Monotone Polygons - the easy case Definition 2.1 A curve γ is x-monotone if any vertical line either does not intersect γ, or it intersect γ in a single point. Definition 2.2 A polygon is x-monotone, if its boundary can be partitioned into two chains that are x monotone. v 0 Figure 1: A polygon and its triangulation. 1

x-monotone not x-monotone Let us think that we are given a monotone polygon as two sorted linked lists of vertices on the upper chain and lower chain. Definition 2.3 A vertex v of a polygon is reflex, if the interior angle at this vertex exceeds π. It is convex if the interior angle at this vertex is smaller than π. A vertex v is an interior cusp of a polygon P if the two adjacent vertices v and v + are both to the left of v or to the right of v. Interior cusp Reflex vertex Lemma 2.4 If a polygon P is x-monotone if and only if it has no interior cups. Proof: Clearly, if it has an interior cusp, then it is not monotone. As for the other direction, let us split P by adding the two x-extreme vertices to P. If both the upper and lower chain are monotone, then P is monotone. Since P has no interior cusp we claim that both chains are monotone. Consider the lower chain, and start walking on it from left to right. If the lower chain is not monotone, then there must be a vertex u where we arrive to it from the left, and leave also through the left. However, since the polygon interior is on our left, it must be that u is an interior cusp. A contradiction. Thus, it must be that the lower chain is monotone. Similar argument applies to the upper chain. 2.1 Triangulating a Monotone Polygon Definition 2.5 We want to triangulate a monotone polygon. Consider the first segments on the upper and lower chains: u 2

v 0 s 2 One segment must be longer in the x-span, and assume it is the first segment s on the top chain (v 0 2 in the figure) - s = v 0 v n 1. Let,,..., v m 1 be the vertices on the bottom chain that lie in the x-range of s, such that v m is to the right of v n 1 in the ordering of the points according to their x-coordinate. The claim is that there is always a diagonal which is valid. This is... v m 1 v n 1 : 2 v 0 We can compute this diagonal in O(m) time. What we did, we broke the monotone polygon into two parts. The part of the left, have a single segment as one of its chains. This is known as mountain polygon: v 0 If we can now triangulate a mountain in linear time, then we can triangulate a monotone polygon in linear time: We steal a mountain of size m in O(m) time, and triangulate it in O(m) time. Namely, triangulating a monotone polygon takes: T (n) = O(m) + T (n m) which is T (n) = O(n). 2.2 Triangulating a mountain Definition 2.6 The two extreme vertices of a mountain polygon, are base vertices. Lemma 2.7 Given a mountain polygon, one of the non-base vertices must be convex. Namely, the internal angle at this vertex is smaller than π. Proof: There are n 2 non base vertices in a polygon P with n vertices. If the angle in all those vertices exceeds π, then the total sum of angle in the polygon P exceeds π(n 2). However, we provide in the previous lecture that the sum of angles of a polygon is exactly π(n 2). A contradiction. One of the non base vertices of a mountain polygon is convex. Lemma 2.8 Every convex vertex in a mountain polygon, which is not a base vertex, is an ear. 3

Proof: If v is a convex vertex than its two neighbors must see each other inside the polygon. As such the diagonal they define is legal, and v is an ear, as the other chain is a single segment that can not intersect this diagonal. v 0 This suggests a natural algorithm for triangulating a mountain polygon P : 1. Compute a list L of all convex vertices of P which are not base vertices. 2. As long as L is not empty (a) Pick a vertex v L, and remove v from L (b) Since v is an ear. Remove the triangle v vv + it defines. (c) Update the angles of v, v + (the two vertices adjacent to v), and add them to L if needed. Namely, we repeatedly remove a ear, till we remain with a triangle. Clearly, handling every ear takes O(1) time. Lemma 2.9 One can triangulate a mountain polygon in linear time. Theorem 2.10 One can triangulate a monotone polygon in linear time. Thus, to triangulate a general polygon, we need to break it into monotone polygons. How do we do it? 3 Vertical Decomposition Given a general polygon P, let us erect a vertical wall through each vertex, till we hit either a floor or a ceiling. If we do this from every vertex, we decompose a polygon into a bunch of vertical trapezoids: Why is this interesting? Well, to decompose a polygon into monotone polygons, we need to kill all interior cups. An interior cups in a vertical decomposition, looks like: 4

So, how can we remove the interior cusp? Note, that if a vertical trapezoid have two vertices on its boundary, we can connect them with a diagonal. Clearly, if we connect all such diagonal, what remains is a decomposition of P into monotone polygons. Lemma 3.1 Given a simple polygon P, and its vertical decomposition, one can decompose P into monotone polygons in linear time. 3.1 Computing Vertical Decomposition Using Sweeping Let use imagine, that we drug a vertical line from x = to x = +. We want to maintain the ordering of segments that intersect the line at every point in time. Let S(t) be the set of segments of P that intersect the sweeping line l(t) x = t. l(1) l(2) l(3) e16 e17 e7 e4 e6 e8 e1 e2 e3 t = 1 t = 2 t = 3 S(1) = {}, S(2) = {e 1, e 2,,, e 17 }, 5

S(3) = {,, e 5,,, } Assume that S(t) is sorted. l(3) When does S(t) change? A: When the sweeping line passes over a vertex. S(t) changes only in vertices. So... Sort the vertices from left to right, and do an update as we go from left to right, stooping only at the vertices. There are several types of events we need to handle: t = 3 1. Replace: l(3) e 17 Remove from S(t) and insert e 17 2. Insert: 7 e 17 Insert and e 17 to S(t). 6

3. Delete: e 17 7 Remove and e 17 from S(t). Observe, that the changes to S(t) are local. Namely, either we delete an element, or insert a new element. How to perform the sweeping? 1. t - the x-coordinate of the sweeping like is a global variable. 2. A data-structure to maintain S(t) (Sorted!). We need a data-structure that enable us to perform insertion and deletions quickly. So... What data-structure to use? Well, any balanced binary tree data structure would work (red-black tree or treaps). 3. Since all the events happened in segment endpoints, sort all the segment endpoints in queue. Thus, sweeping algorithms have a very simple and generic structure: SweepAlg(P ) Q store endpoints of segments of P in x-ord heap. While Q not empty e minheap(q) handle the event e. So, how much time does sweep takes? A: O(n log n) 1. O(n log n) - price for heap. 2. O(n) events, each event takes O(log n) time: Constant number of insertion/deletions from a balanced tree. Theorem 3.2 Sweeping a simple polygon can be done in O(n log n) time. 7

So, what is the connection to vertical decomposition? A: Every time we stop to handle event, we check whether we need to insert a vertical wall, and if so, we insert it. 7 e 17 Q:How do we know whether to erect a vertical wall? A: We can assume that we know for every edge, on which side of it the polygon lies. Q: How do we know how long to make the vertical walls? A:???? A: S(t) is sorted. As such, we can find the segment just below our event vertex, and just above it in O(log n) time. In fact, when we stop and update S(t) we can also erect the vertical walls of the vertical decomposition. Thus, by just modifying the sweeping algorithm, we can get an algorithm that constructs the vertical decomposition of P in O(n log n) time. Theorem 3.3 Given a simple polygon P, one can compute the vertical decomposition of P in O(n log n) time. 8