computational geometry piyush kumar (lecture 5: range searching) welcome to cis5930

17
Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Upload: melissa-garrett

Post on 05-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Computational Geometry

Piyush Kumar(Lecture 5: Range Searching)

Welcome to CIS5930

Page 2: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Range Searching : recap

1D Range search kD trees Range Trees Fractional Cascading

Page 3: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Range Searching

Preprocess a set P of objects for efficiently answering queries.

Typically, P is a collection of geometric objects (points, rectangles, polygons) in Rd.

Query Range, Q : d-rectangles, balls, halfspaces, simplices, etc..

Either count all objects in P Q or report the objects themselves.

Courtesy Bhosle

Page 4: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Q1

Example: Points in R2

Q2

Page 5: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Applications

Databases Spatial databases (G.I.S.) Computer Graphics Robotics Vision

Page 6: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Range Trees (1D)

2 4 5 7 8 12 15 19

6 17 7

7 19151282 4 5

2

4

5 8

12

15Counting ?Reporting?

Page 7: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Range Trees (2d)

P4P3P2P1

P3

P2

P4

P1

P1

P2

P3

P4

P8P7P6P5

P5 P8

P6

P7

Page 8: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Query and Space Complexity(counting)

1D Query : O(log n) Space: O(n)

2D Query : O(log n) Space O(nlogn) Construction time : O(nlogn)

d-D Query : O(logd-1n) Space: O(nlogd-1n) Construction time : O(nlogd-1n)

Page 9: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Kd-Trees

a typical struct Int cut_dim; // dim orthogonal to cutting plane Double cut_val; // location of cutting plane Int size; // number of points in subtree

The best implementation of kd-trees I know of:

http://www.cs.umd.edu/~mount/ANN/

Look at kd_tree.cc and kd_tree.h

Page 10: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

kD-Trees (k-dimensional Trees)

1-d tree : split along median point and recursively build subtrees for the left and right sets.

Higher dimensions : same approach, but cycle through the dimensions. Or, select the next dimension as the one with the widest spread.

Efficiency of query processing drops as dimensions increase (becomes almost linear). However, the space requirement remains linear : O(n.d)

Page 11: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

kD-Trees (Contd.)

a b

c

d

e

f

g

f

n

m

l

k j

ih

o

l

m

j

e

i

g

h

b

k

a

d

c

n

o

Page 12: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Q(n) = 2.Q(n/4) + 1

Q(n) = O(n1/2)

i.e. Query answered in O(n1-1/d + m) time where m is the output size

kD-Trees (Contd.)

Query complexity : How many cells can a query box intersect ?

• Any axis parallel line can intersect atmost 2 of these 4 cells.• Each of these 4 cells contain exactly n/4 points.

Let us consider a facet of the query

Page 13: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Kd-Tree

Summarizing Building (preprocessing time): O(n log

n) Size: O(n) Range queries: O(sqrt(n)+k)

In higher dimensions Building: O(dnlogn) Size: O(dn) Counting Query: O(n1-1/d)

Page 14: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

QuadTrees

4-way partitions Linear space Used in real life more than kd-trees

Page 15: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

Octrees

3D Version of Quadtrees 8 child nodes Applications Range searching Collision detection Mesh generation Visibility Culling Computer games

Page 16: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

General Sets of points

We assumed till now that the x,y coordinates of the points are distinct and do not overlap the coordinates of the query. How do we relax this?

Page 17: Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930

More on the Chalk board…