Type or paste a DOI foundations of multidimensional and metric data structures pdf download into the text box. Further documentation is available here. Not to be confused with Z curve or Z-order.

Four iterations of the Z-order curve. Z-order curve iterations extended to three dimensions.

In mathematical analysis and computer science, functions which are Z-order, Lebesgue curve, Morton order or Morton code map multidimensional data to one dimension while preserving locality of the data points. It was introduced in 1966 by Guy Macdonald Morton.

The z-value of a point in multidimensions is simply calculated by interleaving the binary representations of its coordinate values. The resulting ordering can equivalently be described as the order one would get from a depth-first traversal of a quadtree.

Interleaving the binary coordinate values yields binary z-values as shown. Connecting the z-values in their numerical order produces the recursively Z-shaped curve.

Two-dimensional Z-values are also called as quadkey ones. The Z-ordering can be used to efficiently build a quadtree for a set of points. The basic idea is to sort the input set according to Z-order.

Once sorted, the points can either be stored in a binary search tree and used directly, which is called a linear quadtree, or they can be used to build a pointer based quadtree. Both representations are equivalent and allow for the highest order non-zero bit to be found in constant time. Each square in the quadtree has a side length which is a power of two, and corner coordinates which are multiples of the side length. Given any two points, the derived square for the two points is the smallest square covering both points.