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
public abstract class KDTreeNode<T> extends java.lang.Object implements RealLocalizable, Sampler<T>
Abstract base class for nodes in a KDTree. A KDTreeNode has coordinates and a value. It provides the coordinates via theRealLocalizableinterface. It provides the value viaSampler.get().
-
-
Field Summary
Fields Modifier and Type Field Description KDTreeNode<T>leftLeft child of this node.protected intnnumber of dimensions of the space (that is, k).protected double[]poscoordinates of the node.KDTreeNode<T>rightRight child of this node.protected intsplitDimensiondimension along which this node divides the space.
-
Constructor Summary
Constructors Modifier Constructor Description protectedKDTreeNode(KDTreeNode<T> node)KDTreeNode(RealLocalizable position, int dimension, KDTreeNode<T> left, KDTreeNode<T> right)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract KDTreeNode<T>copy()doublegetDoublePosition(int d)Return the current position in a given dimension.floatgetFloatPosition(int d)Return the current position in a given dimension.doublegetSplitCoordinate()Get the position alonggetSplitDimension()where this node divides the space.intgetSplitDimension()Get the dimension along which this node divides the space.voidlocalize(double[] position)Write the current position into the passed array.voidlocalize(float[] position)Write the current position into the passed array.intnumDimensions()Gets the space's number of dimensions.doublesquDistanceTo(double[] p)Compute the squared distance from p to this node.floatsquDistanceTo(float[] p)Compute the squared distance from p to this node.doublesquDistanceTo(RealLocalizable p)Compute the squared distance from p to this node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.imglib2.RealLocalizable
localize, positionAsDoubleArray, positionAsRealPoint
-
-
-
-
Field Detail
-
n
protected final int n
number of dimensions of the space (that is, k).
-
pos
protected final double[] pos
coordinates of the node.
-
splitDimension
protected final int splitDimension
dimension along which this node divides the space.
-
left
public final KDTreeNode<T> left
Left child of this node. All nodes x in the left subtree havex.pos[splitDimension] <= this.pos[splitDimension].
-
right
public final KDTreeNode<T> right
Right child of this node. All nodes x in the right subtree havex.pos[splitDimension] >= this.pos[splitDimension].
-
-
Constructor Detail
-
KDTreeNode
public KDTreeNode(RealLocalizable position, int dimension, KDTreeNode<T> left, KDTreeNode<T> right)
- Parameters:
position- coordinates of this nodedimension- dimension along which this node divides the spaceleft- left child noderight- right child node
-
KDTreeNode
protected KDTreeNode(KDTreeNode<T> node)
-
-
Method Detail
-
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:EuclideanSpaceGets the space's number of dimensions.- Specified by:
numDimensionsin interfaceEuclideanSpace
-
localize
public final void localize(float[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public final void localize(double[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
getFloatPosition
public final float getFloatPosition(int d)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getFloatPositionin interfaceRealLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
getDoublePosition
public final double getDoublePosition(int d)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getDoublePositionin interfaceRealLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
copy
public abstract KDTreeNode<T> copy()
- Specified by:
copyin interfaceSampler<T>- Returns:
- - A new
Samplerin 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 anArrayCursorfor 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
public final double squDistanceTo(RealLocalizable p)
Compute the squared distance from p to this node.
-
-