Quadtrees?

Carter T Shock ctso at umiacs.umd.edu
Sun Mar 2 06:09:56 CET 1997


> [Discussion of "B-tree with space-filling curve to index the tree"]
> 
> Ahm, you've totally lost me here! I know what B-trees are (did one for
> a database system I wrote), and I've heard of space-filling curves, but
> I can't imagine how a curve can be used to index things. Can you say
> some more about this?

Lessee... if it's a curve, then there is a function that generates it. For
the Morton curve we'll call that function M(x,y). The range and domain of M
are both the set of Integers (i.e. the function is not continuous, but is
defined for all integral values of x and y). So, if we generate values of
M(x,y) for all values of x and y, the result is a series of integers. In
this case it's called the Morton series.

What I'm getting at is that the set of integer x and y is an infinite,
dense matrix of equidistant points in 2 dimensional space. For each of
these points there exists a unique value in the Morton series. This value
is derived by interleaving the bits of the x and y coordinates as described
in previous mail.
   
So.. now we want to index a collection of points in 2 dimensional space
(btw, it all works in any number of dimensions you want). Any index
(B-Trees included) requires that we have some key for each datum we index.
For simplicity's sake, we'll say that the key must have >, <, and ==
defined for it. Now, if you wanted to, you could store off both the x and y
from your points and derive >, <, and == operators that compared the
tuples. Equality is pretty easy, but greater than and less than get a
little funky.. is [2,3] greater than or less than [3,2]? But wait! For any
point (x,y) there exists some value in the morton series M(x,y). M(x,y) is
just an integer and >, <, == are all trivially defined for integers. In
short, you use the morton codes for the points to sort the points in your
index.

You don't have to use a B-Tree.. anything will do, but the B-Tree is
attractive for large data sets used with limited core space. Next mail
shows how to do a linear quadtree.
	-Todd




More information about the mud-dev-archive mailing list