Computational Geometry

Similar documents
Orthogonal range searching. Orthogonal range search

Computational Geometry

Computational Geometry

CMSC 754 Computational Geometry 1

Orthogonal range searching. Range Trees. Orthogonal range searching. 1D range searching. CS Spring 2009

Range Searching and Windowing

Computational Geometry

Computational Geometry. Lecture 17

GEOMETRIC SEARCHING PART 2: RANGE SEARCH

Advanced Algorithm Design and Analysis (Lecture 12) SW5 fall 2005 Simonas Šaltenis E1-215b

Computational Geometry

Range Searching II: Windowing Queries

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

Orthogonal Range Search and its Relatives

Range Reporting. Range Reporting. Range Reporting Problem. Applications

1 The range query problem

Computational Geometry

Lecture 3 February 9, 2010

External-Memory Algorithms with Applications in GIS - (L. Arge) Enylton Machado Roberto Beauclair

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

Orthogonal Range Queries

kd-trees Idea: Each level of the tree compares against 1 dimension. Let s us have only two children at each node (instead of 2 d )

1D Range Searching (cont) 5.1: 1D Range Searching. Database queries

CS Fall 2010 B-trees Carola Wenk

Point Enclosure and the Interval Tree

Approximation Algorithms for Geometric Intersection Graphs

Computation Geometry Exercise Range Searching II

WINDOWING PETR FELKEL. FEL CTU PRAGUE Based on [Berg], [Mount]

11 - Spatial Data Structures

Range Searching. Data structure for a set of objects (points, rectangles, polygons) for efficient range queries.

I/O-Algorithms Lars Arge Aarhus University

Multidimensional Indexing The R Tree

Trapezoid and Chain Methods

Computational Geometry

Module 8: Range-Searching in Dictionaries for Points

Planar Point Location

Data structures for totally monotone matrices

Range-Aggregate Queries Involving Geometric Aggregation Operations

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.

ITEC2620 Introduction to Data Structures

Geometric Data Structures

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

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

Algorithms for Memory Hierarchies Lecture 2

Acceleration Data Structures

Spatial Data Structures

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

I/O-Algorithms Lars Arge

Spatial Data Structures

Geometric data structures:

Geometric Data Structures

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

GEOMETRIC SEARCHING PART 1: POINT LOCATION

Line segment intersection. Family of intersection problems

Ray Tracing Acceleration Data Structures

Clustering Billions of Images with Large Scale Nearest Neighbor Search

Geometric Data Structures

Spatial Data Structures

Multi-way Search Trees. (Multi-way Search Trees) Data Structures and Programming Spring / 25

Breadth-First Search L 1 L Goodrich, Tamassia, Goldwasser Breadth-First Search 1

Box-Trees and R-trees with Near-Optimal Query Time Λ

VQ Encoding is Nearest Neighbor Search

Computational Geometry [csci 3250]

Ray Casting. 3D Rendering. Ray Casting. Ray Casting. Ray Casting. Ray Casting

Spatial Data Structures

Massive Data Algorithmics

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

Quadtrees and Meshing

DFS on Directed Graphs BOS. Outline and Reading ( 6.4) Digraphs. Reachability ( 6.4.1) Directed Acyclic Graphs (DAG s) ( 6.4.4)

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

CS 372: Computational Geometry Lecture 3 Line Segment Intersection

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

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

Part IV. 2D Clipping

CHAPTER 2 REVIEW COORDINATE GEOMETRY MATH Warm-Up: See Solved Homework questions. 2.2 Cartesian coordinate system

Lecture 3: Art Gallery Problems and Polygon Triangulation

CS350: Data Structures AVL Trees

Dynamic Collision Detection

Efficient Algorithmic Techniques for Several Multidimensional Geometric Data Management and Analysis Problems

Balanced Binary Search Trees. Victor Gao

Lesson 05. Mid Phase. Collision Detection

CS 171: Introduction to Computer Science II. Binary Search Trees

(2,4) Trees. 2/22/2006 (2,4) Trees 1

CMPS 2200 Fall 2017 B-trees Carola Wenk

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Lecture 8: Orthogonal Range Searching

Intersection Acceleration

Massive Data Algorithmics

Big Data Analytics. Special Topics for Computer Science CSE CSE April 14

Trapezoidal decomposition:

1 Divide and Conquer Approach

Heaps Outline and Required Reading: Heaps ( 7.3) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Data Organization: Creating Order Out Of Chaos

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Polygon decomposition. Motivation: Art gallery problem

Warped parallel nearest neighbor searches using kd-trees

Computational Geometry

Hidden Surface Elimination: BSP trees

1. Meshes. D7013E Lecture 14

Transcription:

Orthogonal Range Searching omputational Geometry hapter 5 Range Searching Problem: Given a set of n points in R d, preprocess them such that reporting or counting the k points inside a d-dimensional axis-parallel box will be most efficient. esired output-sensitive query time complexity O(k+f(n)) for reporting and O(f(n)) for counting, where f(n)=o(n), e.g. f(n)=logn. Y X Sample application: Report all cities within 00 mile radius of oston. 5. Range Searching n a one-dimensional world, points are real numbers and the query is two numbers (a,b). Simple O(logn) algorithm: Preprocessing: Sort points in O(nlogn). Query: (inary) search for a and b in list in O(logn). List all values in-between. annot be easily generalized to higher dimensions (why not?). a b Range Searching Tree Range tree solution: Sort points. onstruct a binary balanced tree, storing the points in its leaves. ach tree node stores the largest value of its left sub-tree. (keys are stored only in leaves. nternal nodes stores separators for navigating search in the tree) - -2 5 0 - -2 0 3 5 7 3 7 - -2 0 3 5 7 Range Searching in Tree General dea Required time for finding a leaf: O(log n). ind the two boundaries of the given range in the leaves u and v. Report all the leaves in maximal subtrees between u and v. Mark the vertex at which the search paths diverge as V-split. nput Range: 3.5-8.2 V-split -2 5-0 3 7 uild a data structure storing a small number of canonical subsets, such that: The c.s. (canonical subset) may overlap. very query may be answered as the union of a small number of c.s. The geometry of the space enables this. - -2 0 3 5 7 ontinue to find the two boundaries, reporting values in the subtrees: When going left (right), report the entire right (left) subtree. When reaching a leaf, check it exhaustively.

xample 5 V-split 7 canonical subset 2 {9,2,,5} 3 2 20 27 {,7} {7,20} 2-Trees Given a set of points in 2. ound the points by a rectangle. Split the points into two (almost) equal size groups, using a horizontal or vertical line. ontinue recursively to partition the subsets, until they are small enough. anonical subsets are subtrees. {3} 9 7 {22} 22 25 29 3 7 9 2 5 7 20 22 2 25 27 29 3 u v 2 23 canonical subsets are subtrees Partitions 2 space into axis-aligned rectangular regions. Nodes represent partition lines, and leaves represent input points. construction complexity: O() n = T ( n) = n O( n) + 2T 2 n > T ( n) = O( nlog n) 2-Tree L2 L L L L L 6 L 6 G Range ounting/reporting ach node in the tree defines an axis-parallel rectangle in the plane, bounded by the lines marked by this vertex s ancestors. Label each node with the 8 number of points in that L rectangle. 2 2 2 2 L L 6 L L L 6 G G G Range ounting/reporting Given an axis-parallel range query R, search for this range in the tree. Traverse only subtrees which represent regions intersecting R. f a subtree is contained entirely in R: ounting: dd its count. Reporting: L Report entire subtree. 9 L 5 R L 6 2 2 2 3 G L L L 6 L 8 2 G L 8 Runtime omplexity ow much time is spent on internal nodes? The nodes visited are those that are stabbed by R but not contained in R. ow many such nodes are there? Theorem: very side of R stabs O( n) cells of the tree. Proof: xtend the side to a full line (WLOG - horizontal): n the first level it stabs two children. n the next level it stabs (only) two of the four grandchildren. Thus, the recursive equation is: Total query time for reporting: O( n + k). Total query time for counting O( n). Total query time for emptiness???? n = Q( n) = n 2 + 2Q otherwise = O ( n ) 2

Kd-Trees igher imensions or a d-dimensional space: onstruction time: O(d n log n). Space omplexity: O(dn). Query time complexity: O(dn -/d +k). Question: re kd trees useful for non-orthogonal range queries, e.g. disks, convex polygons? act: Using interval trees and segment trees, orthogonal range queries may be solved in O(log d- n+k) time and O(n log d- n) space. Segment Trees Segment trees are structures for storing sets S of n segments, which support the following operations: - insertion of a segment - deletion of segment - stabbing queries: or a given point p, report all segments of S that contain p (that are stabbed by ) n their 2 version, (2 levels trees) answer queries of the form: Preprocess a set S of axis-parallel rectangles, so that for every query point we can report all rectangle containing it in O(log 2 n +k) time, where k is the output size. Segment tree definition The minimal intervals (separating between segments endpoints) determine elementary intervals. onstruct hierarchy of the intervals: binary tree of the minimal intervals (sorted), where each internal node u corresponds to an interval u, which is the union of minimal intervals of its decedent leaves. t also stores a set S u of S of segments. segment s is in S u iff u is the first node from the root, such that s contains u. that is, s contains u but s does not contain parent(u) nput segments Minimal intervals intervals lgorithm for answering stabbing queries procedure report (u: node ; x: point): report all segments of S u ; if u is leaf then finish else { if (u has left child v and x v ) then report(v, x); if (u has left child w and x w ) then report(w, x); } //no need to visit both children Using the segment tree all segment that contain a query point can be reported in time O(log n + k), where k is the number of reported segments. (a bit overkilling can be done using an interval tree) - The output can be expressed as O(log n) canonical sets. Size of a Segment Tree pplications for 2 Query set of rectangles Given a set S of n axis-para rectangles in 2, preprocess S so that given a query point, we can find all points of S inside R in n each level of the tree, a segment s can be stored at at most two nodes. ach segment of appears in at the most O(log n) nodes. onstruction of a segment tree with n intervals is possible in time O(n log n). 3

Query set of rectangles (cont) Given a set S of n rectangle in 2, all intersecting a vertical line l, preprocess S so that given a query point q on l, we can find all rectangle of S containing q in O(log n+k), Query set of rectangles (cont) Given a set S of n rectangle in 2, all crossing a vertical strip l from left to right (their x-projection contains the x-projection of l), preprocess S so that given a query point q inside l, we can find all rectangle of S containing q in O(log n+k), l nswer: uild a segment tree on the intersection of each rectangle with l l nswer: uild a segment tree on the intersection of each rectangle with l Perform a query with q in this tree. Perform a query with q in this tree. q q pplications for 2 2 Segment tree -nalysis Given a set S of n axis-para rectangles in 2, preprocess S so that given a query point, we can find all points of S inside R in nswer: uild a segment tree T on the projections of each rectangle on the x-axis. ach node u in T corresponds to an interval u on the x-axis, and to a set S u of rectangles whose x-projection contains u uild a tree T u on the y-projections of the rectangles in S u To answer a query q=(x 0,y 0 ), find a set of O(log n) nodes of T whose interval u, contains x 0. Query each tree T u with y 0. Space the size of T is O(n log n) ach tree T u has size O( S u log S u ) = O( S u log n ) Total space O(n log 2 n ) Query time: We perform a search in T, giving O( log n) nodes, and perform a search in each such node u, (in O( log S u )= O(log n) ) Total O(log 2 n) onstruction O(n log 2 n ) Range space for points sets Given a set S of n points in 2, preprocess S so that given a query vertical strip R, we can find all points of S inside R in Since we care only about the x-axis of the coordinate, we construct a range tree on their x-coordinates. Once the query strip is given, express the answer as a union of O(log n) subtrees. (that is, canonical sets). The range of reported canonical subset is fully contained inside X(R) the X-projection of R pplications for 2 Given a set S of n points in 2, preprocess S so that given a query axis-parallel rectangle R, we can find all points of S inside R in O(log 2 n+k), where k is the output size irst project the points on the x-axis, and built a range tree T. ach node of T also points to a range tree of the points in these subset, sorted by their Y- coordinate. T

ack to interval trees Given a set S of n segments in, preprocess S so that given a query point q, we can find all segments of S containing q in. Note segment tree answers this query, but needs θ( n log n) space We use interval trees: The root is associated with the set S root(t) of all segments of S containing the point m, where m is the median of the endpoints of all segments of S. lso store lists L root(t) and R root(t) of all endpoints sorted. The left (resp. right) subtree is constructed recursively of all segment completely to the left (right) of m. 5