Homework Exam 1, Geometric Algorithms, 2016



Similar documents
Computational Geometry. Lecture 1: Introduction and Convex Hulls

Optimal 3D Angular Resolution for Low-Degree Graphs

Arrangements And Duality

Line Segment Intersection

Computational Geometry: Line segment intersection

INTERSECTION OF LINE-SEGMENTS

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

Shortest Path Algorithms

1 if 1 x 0 1 if 0 x 1

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

Triangulation by Ear Clipping

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

Topological Treatment of Platonic, Archimedean, and Related Polyhedra

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

39 Symmetry of Plane Figures

Disjoint Compatible Geometric Matchings

MODERN APPLICATIONS OF PYTHAGORAS S THEOREM

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

56 questions (multiple choice, check all that apply, and fill in the blank) The exam is worth 224 points.

HOLES 5.1. INTRODUCTION

Connectivity and cuts

INCIDENCE-BETWEENNESS GEOMETRY

DEGREE CONSTRAINED TRIANGULATION. Roshan Gyawali

Shortest Inspection-Path. Queries in Simple Polygons

Graph Theory Problems and Solutions

n 2 + 4n + 3. The answer in decimal form (for the Blitz): 0, 75. Solution. (n + 1)(n + 3) = n lim m 2 1

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

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Mathematical Induction. Mary Barnes Sue Gordon

EdExcel Decision Mathematics 1

Solving Geometric Problems with the Rotating Calipers *

G.H. Raisoni College of Engineering, Nagpur. Department of Information Technology

Section 13.5 Equations of Lines and Planes

11.1. Objectives. Component Form of a Vector. Component Form of a Vector. Component Form of a Vector. Vectors and the Geometry of Space

Geometry Chapter Point (pt) 1.1 Coplanar (1.1) 1.1 Space (1.1) 1.2 Line Segment (seg) 1.2 Measure of a Segment

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

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

Finding and counting given length cycles

Labeling outerplanar graphs with maximum degree three

Removing Even Crossings

Solutions to Homework 10

Geometry 1. Unit 3: Perpendicular and Parallel Lines

Solutions to Homework 6

Angles and Quadrants. Angle Relationships and Degree Measurement. Chapter 7: Trigonometry

alternate interior angles

Logo Symmetry Learning Task. Unit 5

The number of generalized balanced lines

5.3 The Cross Product in R 3

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

Distributed Computing over Communication Networks: Maximal Independent Set

EQUATIONS and INEQUALITIES

Session 7 Bivariate Data and Analysis

Graphs without proper subgraphs of minimum degree 3 and short cycles

Removing Local Extrema from Imprecise Terrains

Linear Programming I

arxiv: v1 [math.co] 7 Mar 2012

8.1 Min Degree Spanning Tree

E XPLORING QUADRILATERALS

A Linear Online 4-DSS Algorithm

2.1. Inductive Reasoning EXAMPLE A

1(a). How many ways are there to rearrange the letters in the word COMPUTER?

Persistent Data Structures and Planar Point Location

Intersection of Convex Objects: The Method of Separating Axes

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

Largest Fixed-Aspect, Axis-Aligned Rectangle

Geometry Review Flash Cards

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

Geometry 8-1 Angles of Polygons

Quickstart for Desktop Version

GRAPH THEORY LECTURE 4: TREES

Zachary Monaco Georgia College Olympic Coloring: Go For The Gold

Three Lemmas in Geometry

Section 1.1 Linear Equations: Slope and Equations of Lines

Shortcut sets for plane Euclidean networks (Extended abstract) 1

SolidWorks Implementation Guides. Sketching Concepts

arxiv: v1 [cs.cg] 15 Sep 2014

Solutions to old Exam 1 problems

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

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

Geometry: Unit 1 Vocabulary TERM DEFINITION GEOMETRIC FIGURE. Cannot be defined by using other figures.

Discrete Mathematics Problems

Conjunction is true when both parts of the statement are true. (p is true, q is true. p^q is true)

Social Media Mining. Graph Essentials

Mathematics Geometry Unit 1 (SAMPLE)

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

Internet Packet Filter Management and Rectangle Geometry

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

What does the number m in y = mx + b measure? To find out, suppose (x 1, y 1 ) and (x 2, y 2 ) are two points on the graph of y = mx + b.

TOWARDS AN AUTOMATED HEALING OF 3D URBAN MODELS

Lecture 2: Homogeneous Coordinates, Lines and Conics

MA 408 Computer Lab Two The Poincaré Disk Model of Hyperbolic Geometry. Figure 1: Lines in the Poincaré Disk Model

UPPER BOUNDS ON THE L(2, 1)-LABELING NUMBER OF GRAPHS WITH MAXIMUM DEGREE

One advantage of this algebraic approach is that we can write down

Data Structures Fibonacci Heaps, Amortized Analysis

In mathematics, it is often important to get a handle on the error term of an approximation. For instance, people will write

New York State Student Learning Objective: Regents Geometry

Solving Simultaneous Equations and Matrices

Persistent Data Structures

Actually Doing It! 6. Prove that the regular unit cube (say 1cm=unit) of sufficiently high dimension can fit inside it the whole city of New York.

5.1 Midsegment Theorem and Coordinate Proof

Transcription:

Homework Exam 1, Geometric Algorithms, 2016 1. (3 points) Let P be a convex polyhedron in 3-dimensional space. The boundary of P is represented as a DCEL, storing the incidence relationships between the vertices, (half-)edges, and faces in the boundary of P. Assume there are n vertices. There are no vertices of degree 2, and no two adjacent faces are parallel (the description of P is minimal). An xy-silhouette of a convex polyhedron P is defined as a cyclic sequence (cycle) of vertices v 1,..., v k P such that (i) if we remove the third coordinate from each vertex in the sequence, it is a proper description of a convex polygon in the xy-plane, and (ii) for every vertex in the sequence, and for any point on a line segment defined by two consecutive vertices, a line through that vertex or point parallel to the z-axis does not intersect the interior of P. (A proper description of a convex polygon does not include vertices where the interior angle is π, so where the two incident edges are parallel.) Note that two consecutive vertices in the xy-silhouette need not be connected by an edge in P. (a.) (0.5 pnt) An xy-silhouette may not be unique. Explain exactly when the xy-silhouette of a convex polyhedron P is unique and when it is not. Answer: The xy-silhouette is unique if and only if P has no vertical edges (parallel to the z-axis). When there are vertical edges, either the upper endpoint or the lower endpoint can be chosen in the xy-silhouette. If P has a vertical facet but no vertical edges, then the xy-projection of that facet is a line segment and its endpoints are the projections of unique vertices of P, and only these occur in the xy-silhouette. Note that the xy-silhouette is a cyclic sequence of vertices of P and not of the projection of P. Also note that it is cyclic, so a different starting point does not make it a different cyclic sequence. A proof was not asked for. The only essential part of the answer above is the first sentence. (b.) (2 pnt) Give an algorithm that determines an xy-silhouette of a convex polyhedron P in O(n) time, using the standard names of fields of a DCEL (like: IncidentEdge, Next, etc.). The algorithm is passed a single vertex record of some vertex in the boundary of P. As the approach, use a suitable (simple!) traversal of the boundary of P. Write down every constant-time geometric test or operation in words, not in formulas or code. Answer: The approach is to use two phases. In the first, we traverse the boundary of P to find a vertex v with minimum x-coordinate. In the second, we traverse edges and vertices of the boundary of P that have the vertical line property from the definition of xy-silhouette, and extract the xy-silhouette vertices in a cyclic order. Phase 1: Suppose any vertex v of P is given 1. e = IncidentEdge(v) 2. e = Twin(e) 3. while (Next(e )!= e) and (Origin(e ).x >= v.x) 4. do e = Twin(Next(e )) 5. if Origin(e ).x < v.x 6. then v = Origin(e ) and continue at 1. In case there are multiple vertices with the same smallest x-coordinate, we will minimize y-coordinate (lexicographic minimum) as well, and then minimize z-coordinate; this is not in the code above. After phase 1, v is a vertex of P with minimum x-coordinate and phase 2 will start. In the code below, v w represents the direction from the vertex v to the vertex 1

w, and the angle between directions is the (absolute) turn angle required to align the two. It is always π. Phase 2: A vertex v with minimum x-coordinate is given 1. Push v onto a stack S 2. d is the 2D direction of the negative y-axis 3. u = v 4. repeat 5. e = IncidentEdge(v) 6. e = Twin(e) 7. w = Origin(e ) 8. while (Next(e )!= e) 9. do if the xy-projected angle between d and v Origin(Twin(Next(e ))) is smaller than the xy-projected angle between d and v w [ with equality, take the one with lower z-coordinate ] 10. then w = Origin(Twin(Next(e ))); e = Twin(Next(e )) 11. push w onto S 12. while S has at least 3 elements and the last 3 do not make a turn 13. do remove the middle one of them 14. if (w == u) then pop S and return S 15. let d = v w and v = w 15. until False (c.) (0.5 pnt) Argue why your algorithm takes linear time. Answer: The first phase of the algorithm visits a vertex (in the role of v) at most once, because we always change to a vertex with a strictly smaller x-coordinate. For each such vertex, we spend time linear in its degree (number of neighbors). The sum of the degrees of all vertices is bounded by two times the number of edges, and since the vertices and edges of P are a planar graph, this is O(n). Hence, the first phase takes O(n) time. The second phase also visits a vertex (in the role of v) at most once, and exactly the same arguments apply to prove linear time for the second phase. 2. (4 points) Given two sets of red and blue line segments in the plane, denoted R and B, with n and m line segments, respectively. All line segments in R B are disjoint. We want to report every red line segment that is blue-surrounded, meaning that directly to the left and to the right of it, during its full y-span, there is some blue line segment. Give a plane sweep algorithm that takes two sets R and B and reports all blue-surrounded red line segments of R. You may assume that all endpoints of R B have different y-coordinates. (a.) (1 pnt) Define the status of your sweep-line algorithm and describe the status structure. Also describe the event list of your algorithm. Answer: The status for a particular position of the sweep-line l is the set of intersected red and blue line segments of R B, sorted from left to right on intersection point with the sweep line. Each red line segment that intersects the sweep-line stores a Boolean value that is True if it is blue-surrounded above the sweep-line, and False otherwise. The status structure T is a balanced binary search tree storing the status in its leaves. The event list is a list storing all events (upper and lower endpoints of the line segments in R B) in sorted order of decreasing y-coordinate. 2

(b.) (0.5 pnt) Give the initialization of your algorithm. Answer: The initialization consists of computing the event list by sorting all endpoints, and making an empty status structure. (c.) (1.5 pnt) Distinguish in the types of events and describe for each type how it is handled. Answer: There are four types of event points, corresponding to the upper and lower endpoints of the red and of the blue line segments. Note that the algorithm may set the Boolean value of a red segment to False when it is False already (this does not influence correctness). Upper red endpoint p of s: Search with p in T. If the segments directly left and/or right are red, set their Boolean to False, and insert s in T with its Boolean set to False. If the segments directly left and right of p are blue, insert s in T with its Boolean set to True. Lower red endpoint p of s: Search with p in T, and delete s. If its Boolean was True, report it. Upper blue endpoint p of s: Insert s in T. Lower blue endpoint p of s: Search for p in T, and delete s. If directly left and directly right of p there are red segments, then set their Booleans to False. If there is a red segment to only one side and the other side does not have any segments, then set the Boolean of the red segment to False. (d.) (1 pnt) Analyze the running of your algorithm, expressed in n and m. Answer: There are n + m line segments and therefore 2n + 2m endpoints. Each endpoint is an event, and therefore the number of events is O(n+m). Sorting these events in initialization costs O((n + m) log(n + m)) time. Each event involves removing it from the event list (in constant time) and otherwise one insertion or deletion in T, and finding up to two neighbor leaves. Each of these operations takes O(log(n + m)) time. So the total time taken by the algorithm is O((n + m) log(n + m)) time. 3. (2 points) Given a simple polygon P that has no vertices with equal y-coordinate, we are interested in the best horizontal cut. A horizontal cut is a horizontal line segment s (nondegenerate, so of non-zero length) whose endpoints lie on the boundary of P and which itself is fully in P (interior or boundary). A cut therefore splits P in one or two pieces locally above the cut, and one or two pieces locally below the cut. A horizontal cut is best if it minimizes the maximum of: (1) the sum of the areas above the cut, and (2) the sum of the areas below the cut, over all possible horizontal cuts. So it is the most area-balanced cut. A best horizontal cut of a simple polygon with n vertices can be computed in O(n log n) time using a plane sweep, but that is not relevant for this assignment. Here we want to prove a geometric property of the best horizontal cut on which an algorithm can be based. Lemma: Given a simple polygon P with no vertices with equal y-coordinate, the best horizontal cut (i) contains a vertex of P, or (ii) it cuts P into pieces with equal area above and below, or (iii) both. 3

(a.) (1.5 pnt) Prove the lemma. Answer: For a contradiction, assume that the best horizontal cut (i) does not contain a vertex, and (ii) does not cut P into two pieces with equal area above and below. This implies that both endpoints of the cut lie in the interiors of two edges of the boundary of P. We know that these edges are not horizontal, because P does not have any horizontal edges (or else it would have two vertices with the same y-coordinate). Furthermore, the cut splits P into only two pieces which are simple polygons. Assume first that the area of the piece above the cut is strictly larger than the area of the piece below the cut. When can move the cut an arbitrarily small amount upward, keeping its endpoints on the same edges, and decrease the area above the cut. Since we can do it by an arbitrarily small amount, we can make sure that the move does not make the area below the cut larger than the area above the cut. Hence, we have found a better solution than the best cut. A contradiction. If the area of the piece below the cut is strictly larger, we are in a symmetric case and we apply exactly the analogous arguments. (b.) (0.5 pnt) Using the vertex types of Chapter 3, what are the possible types of vertex of P on the best horizontal cut, when it does not result in equal area of the two polygon parts? Answer: This can be either a merge vertex or a split vertex, but nothing else. 4. (1 point) Related to the cut in the previous question is the best diagonal of a simple polygon P. There are three main differences: a diagonal must have both endpoints on vertices of P (see the definition of diagonal in Chapter 3 of the book), its interior lies fully in the interior of P, and it need not be horizontal. The similarity is that the best diagonal also minimizes the area of the larger of the two resulting polygons. Describe an algorithm that computes the best diagonal. The most important aspect of your solution is that it is correct. The second-most important aspect is that it is efficient. Analyze the running time of your algorithm. For this question you do not have to give the details of the algorithm and you may ignore all degenerate cases. The answer should be about half a page. Answer: The simple idea is to try every pair of vertices, test if it gives a diagonal, and if so, compute the areas of the two resulting polygons. 1. For all pairs of vertices p, q in P 2. do 3. for all edges e of P 4. do if the closure of e intersects the interior of pq then take the next p, q 5. Compute the areas on both sides of the diagonal using a standard linear-time area computation 6. Keep it if it is the best one so far O(n 2 ) pairs of vertices are tried, first to test if they are a diagonal in linear time (lines 3 4), and if so, then to compute the areas, also in linear time (lines 5 6). Hence, the algorithm runs in O(n 2 ) (O(n) + O(n)) = O(n 3 ) time. This solution gives the 1 point assigned to this question. You can get an additional point if you see that you can perform a rotational sweep around each vertex (like in exercise 2.14 or 3.14). You can then process any vertex in O(n log n) time, 4

leading to an O(n 2 log n) time algorithm. Assume that we sweep clockwise from a vertex v. We must keep the area of the polygon to the left/counterclockwise from the current diagonal (directed away from v), and update this area by computing only the area in between the previous diagonal and the current diagonal. Or, you can perform the rotational sweep only to find as many diagonals from a vertex as possible. This gives O(n) subpolygons. We compute the area of each in O(n) time overall. Using the angular order of these diagonals, it is now easy to compute the areas of the next clockwise diagonal in O(1) time from the previous one, since the areas are cumulative. The resulting running time is the same, because finding the O(n) diagonals from a vertex already takes O(n log n) time. 5