Package net.imglib2
Class KDTreeNode<T>
java.lang.Object
net.imglib2.KDTreeNode<T>
- Type Parameters:
T
- value type.
- All Implemented Interfaces:
EuclideanSpace
,RealLocalizable
,Sampler<T>
- Direct Known Subclasses:
KDTree.SamplerNode
,KDTree.ValueNode
Abstract base class for nodes in a KDTree. A KDTreeNode has coordinates and a
value. It provides the coordinates via the
RealLocalizable
interface.
It provides the value via Sampler.get()
.- Author:
- Tobias Pietzsch
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal KDTreeNode<T>
Left child of this node.protected final int
number of dimensions of the space (that is, k).protected final double[]
coordinates of the node.final KDTreeNode<T>
Right child of this node.protected final int
dimension along which this node divides the space. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
KDTreeNode
(KDTreeNode<T> node) KDTreeNode
(RealLocalizable position, int dimension, KDTreeNode<T> left, KDTreeNode<T> right) -
Method Summary
Modifier and TypeMethodDescriptionabstract KDTreeNode<T>
copy()
final double
getDoublePosition
(int d) Return the current position in a given dimension.final float
getFloatPosition
(int d) Return the current position in a given dimension.final double
Get the position alonggetSplitDimension()
where this node divides the space.final int
Get the dimension along which this node divides the space.final void
localize
(double[] position) Write the current position into the passed array.final void
localize
(float[] position) Write the current position into the passed array.final int
Gets the space's number of dimensions.final double
squDistanceTo
(double[] p) Compute the squared distance from p to this node.final float
squDistanceTo
(float[] p) Compute the squared distance from p to this node.final double
Compute the squared distance from p to this node.
-
Field Details
-
n
protected final int nnumber of dimensions of the space (that is, k). -
pos
protected final double[] poscoordinates of the node. -
splitDimension
protected final int splitDimensiondimension along which this node divides the space. -
left
Left child of this node. All nodes x in the left subtree havex.pos[splitDimension] <= this.pos[splitDimension]
. -
right
Right child of this node. All nodes x in the right subtree havex.pos[splitDimension] >= this.pos[splitDimension]
.
-
-
Constructor Details
-
KDTreeNode
- Parameters:
position
- coordinates of this nodedimension
- dimension along which this node divides the spaceleft
- left child noderight
- right child node
-
KDTreeNode
-
-
Method Details
-
getSplitDimension
public final int getSplitDimension()Get the dimension along which this node divides the space.- Returns:
- splitting dimension.
-
getSplitCoordinate
public final double getSplitCoordinate()Get the position alonggetSplitDimension()
where this node divides the space.- Returns:
- splitting position.
-
numDimensions
public final int numDimensions()Description copied from interface:EuclideanSpace
Gets the space's number of dimensions.- Specified by:
numDimensions
in interfaceEuclideanSpace
-
localize
public final void localize(float[] position) Description copied from interface:RealLocalizable
Write the current position into the passed array.- Specified by:
localize
in interfaceRealLocalizable
- Parameters:
position
- receives current position
-
localize
public final void localize(double[] position) Description copied from interface:RealLocalizable
Write the current position into the passed array.- Specified by:
localize
in interfaceRealLocalizable
- Parameters:
position
- receives current position
-
getFloatPosition
public final float getFloatPosition(int d) Description copied from interface:RealLocalizable
Return the current position in a given dimension.- Specified by:
getFloatPosition
in interfaceRealLocalizable
- Parameters:
d
- dimension- Returns:
- dimension of current position
-
getDoublePosition
public final double getDoublePosition(int d) Description copied from interface:RealLocalizable
Return the current position in a given dimension.- Specified by:
getDoublePosition
in interfaceRealLocalizable
- Parameters:
d
- dimension- Returns:
- dimension of current position
-
copy
- Specified by:
copy
in interfaceSampler<T>
- Returns:
- - A new
Sampler
in the same state accessing the same values. It does NOT copy T, just the state of theSampler
. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for anArrayCursor
for example)
-
squDistanceTo
public final float squDistanceTo(float[] p) Compute the squared distance from p to this node. -
squDistanceTo
public final double squDistanceTo(double[] p) Compute the squared distance from p to this node. -
squDistanceTo
Compute the squared distance from p to this node.
-