Computational Geometry

Similar documents
Trapezoidal Maps. Notes taken from CG lecture notes of Mount (pages 60 69) Course page has a copy

Computational Geometry

GEOMETRIC SEARCHING PART 1: POINT LOCATION

Computational Geometry

Randomized incremental construction. Trapezoidal decomposition: Special sampling idea: Sample all except one item

Project 3: Point Location

Chapter 8. Voronoi Diagrams. 8.1 Post Oce Problem

Computational Geometry

Problem: Polygon Triangulation. Trapezoidal Map. Solution via Trapezoidal Map. The trapezoidal map of non-crossing line segments

Range Searching II: Windowing Queries

Planar Point Location

CS 532: 3D Computer Vision 14 th Set of Notes

K-structure, Separating Chain, Gap Tree, and Layered DAG

Problem Set 3. MATH 776, Fall 2009, Mohr. November 30, 2009

Ray Tracing: Intersection

Line segment intersection. Family of intersection problems

Min st-cut Oracle for Planar Graphs with Near-Linear Preprocessing Time

Polygon Partitioning. Lecture03

Planar graphs. Math Prof. Kindred - Lecture 16 Page 1

Exercise set 2 Solutions

1. Meshes. D7013E Lecture 14

Elementary maths for GMT. Algorithm analysis Part II

Trapezoidal decomposition:

Computational Geometry

Advanced Algorithms Computational Geometry Prof. Karen Daniels. Fall, 2012

CMSC 754 Computational Geometry 1

Motion Planning. O Rourke, Chapter 8

Mesh Basics: Definitions, Topology & Data Structures. Standard Graph Definitions

January 10-12, NIT Surathkal Introduction to Graph and Geometric Algorithms

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

The Geometry of Carpentry and Joinery

Computational Geometry Lecture Duality of Points and Lines

arxiv: v1 [cs.cg] 8 Jan 2018

Quadtrees and Meshing

Line Arrangements. Applications

Computational Geometry. Lecture 17

Computational Geometry

Connected Components of Underlying Graphs of Halving Lines

Computational Geometry

RASTERIZING POLYGONS IN IMAGE SPACE

Line Arrangement. Chapter 6

CS6100: Topics in Design and Analysis of Algorithms

Field: We have been doing geometry eg linear programming. But in computational geometry, key difference in focus: low dimension d

LAMC Advanced Circle October 9, Oleg Gleizer. Warm-up

Embedded graphs. Sasha Patotski. Cornell University November 24, 2014

Algorithms for GIS:! Quadtrees

Algorithms for GIS. Spatial data: Models and representation (part I) Laura Toma. Bowdoin College

SPERNER S LEMMA MOOR XU

How many colors are needed to color a map?

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Lecture 4: Trees and Art Galleries

The Visibility Problem and Binary Space Partition. (slides by Nati Srebro)

Lecture 16: Voronoi Diagrams and Fortune s Algorithm

Discrete Mathematics I So Practice Sheet Solutions 1

Computational Geometry

Week 7 Convex Hulls in 3D

Range Searching and Windowing

5 Graphs

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm

1 The range query problem

Reversible Hyperbolic Triangulations

The Dominating Set Problem in Intersection Graphs

An Implementation of a Near-Linear Polygon Triangulation Algorithm for General Polygons

Voronoi diagram and Delaunay triangulation

Fixed-Parameter Algorithms, IA166

: Mesh Processing. Chapter 8

Balanced Box-Decomposition trees for Approximate nearest-neighbor. Manos Thanos (MPLA) Ioannis Emiris (Dept Informatics) Computational Geometry

HW Graph Theory SOLUTIONS (hbovik) - Q

Elements of Graph Theory

Lecture 3: Art Gallery Problems and Polygon Triangulation

Monotone Paths in Geometric Triangulations

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Wolfgang Mulzer Institut für Informatik. Planar Delaunay Triangulations and Proximity Structures

Subdivision Of Triangular Terrain Mesh Breckon, Chenney, Hobbs, Hoppe, Watts

Range Reporting. Range reporting problem 1D range reporting Range trees 2D range reporting Range trees Predecessor in nested sets kd trees

CS 532: 3D Computer Vision 11 th Set of Notes

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

Planar Graph (7A) Young Won Lim 6/20/18

Solutions to Problem Set 1

Convex Hulls in 3D. Definitions. Size of a Convex Hull in 3D. Collision detection: The smallest volume polyhedral that contains a set of points in 3D.

Notes and Answers to Homework Exam 1, Geometric Algorithms, 2017

Speeding Up the Incremental Construction of the Union of Geometric Objects in Practice

CMPS 3130/6130 Computational Geometry Spring Voronoi Diagrams. Carola Wenk. Based on: Computational Geometry: Algorithms and Applications

Reachability in K 3,3 -free and K 5 -free Graphs is in Unambiguous Logspace

Matching and Planarity

Spatial Data Structures

Henneberg construction

Lecture 20 : Trees DRAFT

Orthogonal range searching. Orthogonal range search

Pebble Sets in Convex Polygons

Testing Bipartiteness of Geometric Intersection Graphs David Eppstein

MATH 350 GRAPH THEORY & COMBINATORICS. Contents

Average case analysis of dynamic geometric optimization

Road Map Methods. Including material from Howie Choset / G.D. Hager S. Leonard

8 Colouring Planar Graphs

Optimal Expected-Case Planar Point Location

Range Reporting. Range Reporting. Range Reporting Problem. Applications

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

SAMPLING AND THE MOMENT TECHNIQUE. By Sveta Oksen

External-Memory Algorithms for Processing Line Segments in Geographic Information Systems 1

Transcription:

Planar point location

Point location Introduction Planar point location Strip-based structure Point location problem: Preprocess a planar subdivision such that for any query point q, the face of the subdivision containing q can be given quickly (name of the face) From GPS coordinates, find the region on a map where you are located Subroutine for many other geometric problems (Chapter 13: motion planning, or shortest path computation)

Point location Introduction Planar point location Strip-based structure non-crossing Planar subdivision: Partition of the plane by a set of non-crossing line segments into vertices, edges, and faces crossing non-crossing: disjoint, or at most a shared endpoint

Point location Introduction Planar point location Strip-based structure Data structuring question, so interest in query time, storage requirements, and preprocessing time Question: What is the one-dimensional analogue?

First solution Introduction Planar point location Strip-based structure Idea: Draw vertical lines through all vertices, then do something for every vertical strip that appears

First solution Introduction Planar point location Strip-based structure

In one strip Introduction Planar point location Strip-based structure Inside a single strip, there is a well-defined bottom-to-top order on the line segments Use this for a balanced binary search tree that is valid if the query point is in this strip (knowing between which edges we are is knowing in which face we are)

Solution with strips Introduction Planar point location Strip-based structure search tree on x-coordinate

Solution with strips Introduction Planar point location Strip-based structure To answer a query with q = (q x,q y ), search in the main tree with q x to find a leaf, then follow the pointer to search in the tree that is correct for the strip that contains q x Question: What are the storage requirements and what is the query time of this structure?

Solution with strips Introduction Planar point location Strip-based structure n 4 n 4 strips

Solution with strips Introduction Planar point location Strip-based structure

Different idea Introduction The vertical strips idea gave a refinement of the original subdivision, but the number of faces went up from linear in n to quadratic in n Is there a different refinement whose size remains linear, but in which we can still do point location queries easily?

Suppose we draw vertical extensions from every vertex up and down, but only until the next line segment Assume the input line segments are not vertical Assume every vertex has a distinct x-coordinate Assume we have a bounding box R that encloses all line segments that define the subdivision This is called the vertical decomposition or trapezoidal decomposition

R

faces The vertical decomposition has triangular and trapezoidal faces

faces Every face has a vertical left and/or right side that is a vertical extension, and is bounded from above and below by some line segment of the input The left and right sides are defined by some endpoint of a line segment top( ) top( ) leftp( ) rightp( ) leftp( ) rightp( ) bottom( ) bottom( )

faces Every face is defined by no more than four line segments For any face, we ignore vertical extensions that end on top( ) and bottom( )

Neighbors of faces Introduction Two trapezoids (including triangles) are neighbors if they share a vertical side Each trapezoid has 1, 2, 3, or 4 neighbors

Neighbors of faces Introduction A trapezoid could have many neighbors if vertices had the same x-coordinate

Representation Introduction We could use a DCEL to represent a vertical decomposition, but we use a more direct & convenient structure Every face is an object; it has fields for top( ), bottom( ), leftp( ), and rightp( ) (two line segments and two vertices) Every face has fields to access its up to four neighbors Every line segment is an object and has fields for its endpoints (vertices) and the name of the face in the original subdivision directly above it Each vertex stores its coordinates

Representation Introduction f 1 f 1 f 1 f 1 f 2 f 2 f 1 f 1 f 3 f 3 f 1 f 1 f 1 R

Representation Introduction Any trapezoid can find out the name of the face it is part of via bottom( ) and the stored name of the face

Complexity Introduction A vertical decomposition of n non-crossing line segments inside a bounding box R, seen as a proper planar subdivision, has at most 6n + 4 vertices and at most 3n + 1 trapezoids leftp( 1 ) s i leftp( 2 ) s i leftp( 3 )

Point location preprocessing The input to planar point location is a planar subdivision, for example in DCEL format First, store with each edge the name of the face above it (our structure will find the edge below any query point) Then extract the edges to define a set S of non-crossing line segments; ignore the DCEL otherwise

Point location solution We will use randomized incremental construction to build, for a set S of non-crossing line segments, a vertical decomposition T of S and R a search structure D whose leaves correspond to the trapezoids of T The simple idea: Start with R, then add the line segments in random order and maintain T and D

Point location solution Let s 1,...,s n be the n line segments in random order Let T i be the vertical decomposition of R and s 1,...,s i, and let D i be the search structure obtained by inserting s 1,...,s i in this order T 0 D 0 R R

Point location solution Let s 1,...,s n be the n line segments in random order Let T i be the vertical decomposition of R and s 1,...,s i, and let D i be the search structure obtained by inserting s 1,...,s i in this order T 1 D 1 3 p 1 1 s 1 p 1 q 1 4 q 1 2 s 1 R 1 2 3 4

Point location solution D has x-nodes, which store an endpoint, and y-nodes, which store a line segment s j For any query point t, we only test at an x-node: Is t left or right of the vertical line through the stored point? For any query point t, we only test at an y-node: Is t below or above the stored line segment? We will guarantee that the question at a y-node is only asked if the query point t is between the vertical lines through p j and q j, if line segment s j = p j q j is stored

Point location solution T 1 D 1 3 p 1 1 s 1 p 1 q 1 4 q 1 2 s 1 R 1 2 3 4

Point location solution T 1 D 1 3 p 1 1 s 1 p 1 q 1 2 s 2 4 p 2 q 2 R s 1 q 1 1 2 3 4

Point location solution T 1 D 1 1 3 s 1 p 1 q 1 p 1 q 1 s 2 p 2 q 2 R s 1 1 3

Point location solution T 2 D 1 8 1 3 s 1 p 1 q 1 9 6 s 2 q 2 5 p 2 7 R p 1 q 1 s 1 1 3

Point location solution D 2 p T 1 2 8 1 3 s 1 p 1 q 1 6 s 2 q 2 5 p 2 7 R s 1 q 1 9 1 p 2 3 5 s 2 s 2 q 2 9 7 6 8

Point location solution We want only one leaf in D to correspond to each trapezoid; this means we get a search graph instead of a search tree It is a directed acyclic graph, or DAG, hence the name D

Point location solution D 2 T 2 p 1 8 1 3 s 1 p 1 q 1 6 s 2 q 2 5 p 2 7 R s 1 q 1 9 1 p 2 3 5 s 2 s 2 q 2 9 7 6 8

Point location query Introduction A point location query is done by following a path in the search structure D to a leaf, then following its pointer to a trapezoid of T, then accessing bottom(..) of this trapezoid, and reporting the name of the face stored with it

Point location query Introduction D 2 T 2 p 1 8 1 3 s 1 p 1 q 1 6 s 2 q 2 5 p 2 7 R s 1 q 1 9 1 p 2 3 5 s 2 s 2 q 2 9 7 6 8

The incremental step Introduction Suppose we have D i 1 and T i 1, how do we add s i? Because D i 1 is a valid point location structure for s 1,...,s i 1, we can use it to find the trapezoid of T i 1 that contains p i, the left endpoint of s i Then we use T i 1 to find all other trapezoids that intersect s i

Find intersected trapezoids q i 0 s i p i

Find intersected trapezoids q i 0 s i p i

Find intersected trapezoids 0 1 p i 2 s i 3 4 6 5 q i 7

Find intersected trapezoids 0 1 p i 2 s i 3 4 6 5 q i 7

Find intersected trapezoids After locating the trapezoid that contains p i, we can determine all k trapezoids that intersect s i in O(k) time by traversing T i 1

2 5 6 7 0 1 3 4

2 5 6 7 0 1 3 4

We can update the vertical decomposition in O(k) time as well

has k leaves that are no longer valid as leaves; they become internal nodes We find these using the pointers from T i 1 to D i 1 From the update of the vertical decomposition T i 1 into T i we know what new leaves we must make for D i All new nodes besides the leaves are x-nodes with p i and q i and y-nodes with s i

D i 1 T i 1 0 4 5 6 1 7 9 2 8 3

D i 1 T i 0 4 5 6 1 7 9 2 8 3 leaves for the new trapezoids in T i

D i 1 T i s i s i s i s i s i s i s i s i leaves for the new trapezoids in T i

D i 1 T i p i s i s i s i s i s i s i q i s i s i s i s i leaves for the new trapezoids in T i

Observations Introduction For a single update step, adding s i and updating T i 1 and D i 1, we observe: If s i intersects k i trapezoids of T i 1, then we will create O(k i ) new trapezoids in T i We find the k i trapezoids in time linear in the search path of p i in D i 1, plus O(k i ) time We update by replacing k i leaves by O(k i ) new internal nodes and O(k i ) new leaves The maximum depth increase is three nodes

Questions Introduction Question: In what case is the depth increase three nodes? Question: We noticed that the directed acyclic graph D is binary in its out-degree, what is the maximum in-degree?

A common but special update 0 s i p i If p i was already an existing vertex, we search in D i 1 with a point a fraction to the right of p i on s i

Order matters Storage analysis Query time analysis Randomized incremental construction Randomized incremental construction, where does it matter? The vertical decomposition T i is independent of the insertion order among s 1,...,s i D i can be different for many orders of s 1,...,s i The number of nodes in D i depends on the order The depth of search paths in D i depends on the order

Order matters Storage analysis Query time analysis Randomized incremental construction p 1 q 1 s 1 p 2 s 1 s 2 s 3 s 4 s 5 q 2 s 2 p 3 q 5 s 5

Order matters Storage analysis Query time analysis Randomized incremental construction p 1 p 2 q 1 s 2 s 3 s 1 s 4 s 5 q 2 s 1 p 4 s 2 p 3 q 4 q 3 s 4 p 5 s 3 q 5 s 5

Order matters Storage analysis Query time analysis Randomized incremental construction s 1 s 2 s 3 s 4 s 1 s 2 s 3 s 4 s 8 s 7 s 6 s 5 s 5 s 6 s 7 s 8

Storage of the structure Order matters Storage analysis Query time analysis The vertical decomposition structure T always uses linear storage D can use anything between linear and quadratic storage We analyse the expected number of new nodes when adding s i, using backwards analysis (of course)

Storage of the structure Order matters Storage analysis Query time analysis Backwards analysis in this case: Suppose we added s i and have computed T i and D i. All line segments (existing in T i ) had the same probability of having been the last one added

Storage of the structure Order matters Storage analysis Query time analysis For each of the i line segments, we can see how many trapezoids would have been created if it were the last one added 4 9 3 6 4 5 3

Storage of the structure Order matters Storage analysis Query time analysis For each of the i line segments, we can see how many trapezoids would have been created if it were the last one added 4 9 3 6 4 5 3

Storage of the structure Order matters Storage analysis Query time analysis For each of the i line segments, we can see how many trapezoids would have been created if it were the last one added 4 9 3 6 4 5 3

Storage of the structure Order matters Storage analysis Query time analysis The number of created trapezoids is linear in the number of deleted trapezoids (leaves of D i 1 ), or intersected trapezoids by s i in T i 1 ; this is linear in k i We will analyze K i = i j=1 [no. of trapezoids created if s j were last]

Storage of the structure Order matters Storage analysis Query time analysis Consider K i from the trapezoid perspective : For any trapezoid, there are at most four line segments whose insertion would have created it ( top( ), bottom( ), leftp( ), and rightp( ) )

Storage of the structure Order matters Storage analysis Query time analysis Consider K i from the trapezoid perspective : For any trapezoid, there are at most four line segments whose insertion would have created it ( top( ), bottom( ), leftp( ), and rightp( ) )

Storage of the structure Order matters Storage analysis Query time analysis Consider K i from the trapezoid perspective : For any trapezoid, there are at most four line segments whose insertion would have created it ( top( ), bottom( ), leftp( ), and rightp( ) )

Storage of the structure Order matters Storage analysis Query time analysis We know: There are at most 3i + 1 trapezoids in a vertical decomposition of i line segments in R Hence, K i = T i [no. of segments that would create ] T i 4 = 12i + 4

Storage of the structure Order matters Storage analysis Query time analysis Since K i is defined as a sum over i line segments, the average number of trapezoids in T i created by s i is at most (12i + 4)/i 13 Since the expected number of new nodes is at most 13 in every step, the expected size of the structure after adding n line segments is O(n)

Query time of the structure Order matters Storage analysis Query time analysis Fix any point q in the plane as a query point, we will analyze the probability that inserting s i makes the search path to q longer

Query time of the structure Order matters Storage analysis Query time analysis Backwards analysis: Take the situation after s i has been added, and ask the question: How many of the i line segments made the search path to q longer? q

Query time of the structure Order matters Storage analysis Query time analysis Backwards analysis: Take the situation after s i has been added, and ask the question: How many of the i line segments made the search path to q longer? The search path to q only became longer if q is in a trapezoid that was just created by the latest insertion! At most four line segments define the trapezoid that contains q, so the probability is 4/i

Query time of the structure Order matters Storage analysis Query time analysis We analyze n [search path became longer due to i-th addition] i=1 n i=1 4/i = 4 n i=1 1/i 4(1 + log e n) So the expected query time is O(logn)

Result Introduction Order matters Storage analysis Query time analysis Theorem: Given a planar subdivision defined by a set of n non-crossing line segments in the plane, we can preprocess it for planar point location queries in O(n log n) expected time, the structure uses O(n) expected storage, and the expected query time is O(logn)

Speeding up point location Algorithm of a simple polygon For a simple polygon we want to compute the vertical decomposition faster. Question: What is the bottleneck in the algorithm for planar subdivisions?

Speeding up point location Speeding up point location Algorithm Idea: For certain values of i: batch locate line segments of polygon in T i (and D i ) by tracing the polygon in the vertical decomposition, i.e., traverse T i following the polygon boundary when inserting a line segment, use corresponding node in D i as start.

Speeding up queries Introduction Speeding up point location Algorithm Fix any point q in the plane as a query point. Assume we have located q in D j. How long does it take to locate q in D k?

Speeding up queries Introduction Speeding up point location Algorithm We analyze k [search path became longer due to i-th addition] i=j+1 k i=j+1 4/i = 4 k i=j+1 1/i 4log e (k/j) So the expected query time is O(log(k/j))

When to trace: Iterated logarithm Speeding up point location Algorithm log (h) n := loglog...logn }{{} h times log n := max{h : log (h) n 1} example: log (2 6 5536) = 5 N(h) := n log (h) n, 0 h log n

Algorithm Introduction Speeding up point location Algorithm Construct vertical decomposition as before, but 1.) for i = N(1),...,N(log n): after inserting s i trace the polygon in T i 2.) locate new line segments by query starting at node of D i found by tracing

: Tracing Introduction Speeding up point location Algorithm We already analyzed: tracing a random segment takes O(1) expected time. Tracing the polygon in T i takes O(n) expected time, i = N(1),...,N(log n). Tracing log (n) times: O(nlog (n)) expected time

: Query Introduction Speeding up point location Algorithm Time needed for the queries for i = N(h 1) + 1,...,N(h) together: ( ) ( ) N(h) i n O log O N(h) log n N(h 1) i=n(h 1)+1 log (h 1) n O(N(h)log h n) ( ) n = O log (h) log h n n = O(n) Summing over all i: O(nlog n) expected time.

Result Introduction Speeding up point location Algorithm Theorem: Given a simple polygon with n vertices, we can preprocess it for planar point location queries in O(nlog n) expected time, the structure uses O(n) expected storage, and the expected query time is O(logn) Corollary: We can compute a triangulation of a simple polygon in O(nlog n) expected time using O(n) storage. (Exercise) Fact: There is a deterministic linear-time algorithm for triangulating a simple polygon.