A node is a closed subset of . Denote the set of all nodes by and let . A node is called a descendant of a node if and . If is a descendant of , then is called an ascendant of . A node is called a child of a node if is a descendant of and there is no descendant of which would also be an ascendant of . If is a child of , then is called a parent of .
A binary space-partitioning tree or a bsp-tree, is a directed graph , such that
.
.
either has no children or it has exactly two children and such that and , where refers to the interior of a point-set.
These definitions imply that is a binary tree, explaining the name. A node which has no children is called a leaf node, while the unique node which has no parent is called the root node. A node which is not a leaf node is called a split node. Two nodes which have the same parent are called siblings.
A point BSP-tree is a pair such that
is a BSP-tree, where .
, where are finite sets.
.
is not a leaf node .
A kd-tree is a BSP-tree with the restriction that the set of all nodes is restricted to closed axis-aligned boxes. Let a split-node in a kd-tree have children and . Then there is a unique axis-aligned plane which passes through the points in , called the splitting plane of . The index of the standard basis axis which corresponds to the normal of this plane is called the splitting axis.
A point kd-tree is a point bsp-tree which is also a kd-tree.
A BSP-tree makes it possible to design efficient algorithms for several geometric problems. Such problems include ray casting, nearest neighbor searching, and range searching. The efficiency of these algorithms rely on the ability to skip exploring a large part of the space if that is known not to affect the result. The BSP-tree is effectively a multi-dimensional generalization of the binary tree. In practice, kd-trees offer the best properties of the BSP-trees, from many point of views.
Restricting the splitting planes to be orthogonal with the standard basis axes has a number of advantages. Some of these are:
A plane can be described by a single integer (the splitting axis), and a real number (distance of the plane from the origin). In contrast, arbitrary planes require storage in .
It can be tested with a single comparison on which side of the splitting plane a point is. Because there is no arithmetic involved, there are no numerical problems with rounding: the result is exact. In contrast, arbitrary planes require time in , and the result might be wrong due numerical problems.
There are splitting rules which are easy to compute and result in excellent performance for nearest neighbor searching and ray casting. In contrast, with arbitrary planes, to the best of our knowledge, there is currently no known splitting rules that would have both of these properties.
When doing nearest neighbor searching, there is a technique to incrementally compute the exact distance from the search point to the nearest node. This allows for more efficient culling of space which in turn increases performance. In contrast, this is very hard to achieve with arbitrary splitting planes because the complexities of the nodes are not bounded.