public class KDTreeImpl extends Object
The nodes in the tree are arranged in Eytzinger layout (children of i are at 2i and 2i+1). Additionally, pivot indices are chosen such that "leaf layers" are filled from the left.
For example 10 nodes will always be arranged like this:
0
/ \
1 2
/ \ / \
3 4 5 6
/ \ /
7 8 9
never like this:
0
/ \
1 2
/ \ / \
3 4 5 6
/ / /
7 8 9
By choosing pivots in this way, the tree structure is fully determined. For every node index, the child indices can be calculated without dependent reads. And iff the calculated child index is less than the number of nodes, the child exists.
| Constructor and Description |
|---|
KDTreeImpl(KDTreePositions positions) |
| Modifier and Type | Method and Description |
|---|---|
int |
depth() |
double |
getDoublePosition(int i,
int d) |
int |
left(int i)
Get the left child of node
i. |
int |
numDimensions() |
int |
parent(int i)
Get the parent of node
i. |
int |
right(int i)
Get the right child of node
i. |
int |
root()
Get the root node of the tree.
|
int |
size() |
int |
splitDimension(int i)
Get the dimension along which node
i divides the space. |
double |
squDistance(int i,
double[] pos)
Compute the squared distance from node
i to pos. |
float |
squDistance(int i,
float[] pos)
Compute the squared distance from node
i to pos. |
double |
squDistance(int i,
RealLocalizable pos)
Compute the squared distance from node
i to pos. |
public KDTreeImpl(KDTreePositions positions)
public int root()
public int left(int i)
i.i - node index-1 if no left child existspublic int right(int i)
i.i - node index-1 if no right child existspublic int parent(int i)
i.i - node indexpublic int splitDimension(int i)
i divides the space.i - node indexpublic double getDoublePosition(int i,
int d)
public float squDistance(int i,
float[] pos)
i to pos.public double squDistance(int i,
double[] pos)
i to pos.public double squDistance(int i,
RealLocalizable pos)
i to pos.public int numDimensions()
public int size()
public int depth()
Copyright © 2009–2024 ImgLib2. All rights reserved.