org.ddogleg.nn.wrap
Class KdTreeNearestNeighbor<D>
- java.lang.Object
-
- org.ddogleg.nn.wrap.KdTreeNearestNeighbor<D>
-
- All Implemented Interfaces:
- NearestNeighbor<D>
public class KdTreeNearestNeighbor<D> extends java.lang.Object implements NearestNeighbor<D>
Wrapper aroundKdTreeforNearestNeighbor
-
-
Constructor Summary
Constructors Constructor and Description KdTreeNearestNeighbor()KdTreeNearestNeighbor(KdTreeSearch1 search, KdTreeSearchN searchN, AxisSplitter<D> splitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidfindNearest(double[] point, double maxDistance, int numNeighbors, FastQueue<NnData<D>> result)Searches for the N nearest neighbor to the specified point.booleanfindNearest(double[] point, double maxDistance, NnData<D> result)Searches for the nearest neighbor to the specified point.voidinit(int N)Initializes data structures.voidsetPoints(java.util.List<double[]> points, java.util.List<D> data)Specifies the set of points which are to be searched.
-
-
-
Constructor Detail
-
KdTreeNearestNeighbor
public KdTreeNearestNeighbor(KdTreeSearch1 search, KdTreeSearchN searchN, AxisSplitter<D> splitter)
-
KdTreeNearestNeighbor
public KdTreeNearestNeighbor()
-
-
Method Detail
-
init
public void init(int N)
Description copied from interface:NearestNeighborInitializes data structures.- Specified by:
initin interfaceNearestNeighbor<D>- Parameters:
N- Dimension of input data
-
setPoints
public void setPoints(java.util.List<double[]> points, java.util.List<D> data)Description copied from interface:NearestNeighborSpecifies the set of points which are to be searched.- Specified by:
setPointsin interfaceNearestNeighbor<D>- Parameters:
points- Set of points.data- (Optional) Associated data. Can be null.
-
findNearest
public boolean findNearest(double[] point, double maxDistance, NnData<D> result)Description copied from interface:NearestNeighborSearches for the nearest neighbor to the specified point. The neighbor must be within maxDistance.NOTE: How distance is measured is not specified here. See the implementation's documentation. Euclidean distance squared is common.
- Specified by:
findNearestin interfaceNearestNeighbor<D>- Parameters:
point- A point being searched for.maxDistance- Maximum distance (inclusive, e.g. d ≤ maxDistance) a neighbor can be from point. Values<0 will be set to the maximum distance.result- Storage for the result.- Returns:
- true if a match within the max distance was found.
-
findNearest
public void findNearest(double[] point, double maxDistance, int numNeighbors, FastQueue<NnData<D>> result)Description copied from interface:NearestNeighborSearches for the N nearest neighbor to the specified point. The neighbors must be within maxDistance.NOTE: How distance is measured is not specified here. See the implementation's documentation. Euclidean distance squared is common.
- Specified by:
findNearestin interfaceNearestNeighbor<D>- Parameters:
point- A point being searched for.maxDistance- Maximum distance (inclusive, e.g. d ≤ maxDistance) the neighbor can be from point. Values<0 will be set to the maximum distance.numNeighbors- The number of neighbors it will search for.result- Storage for the result. Must be empty before calling. Must support grow() function.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG