|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.savarese.spatial.NearestNeighbors<Coord,P,V>
public class NearestNeighbors<Coord extends java.lang.Number & java.lang.Comparable<? super Coord>,P extends Point<Coord>,V>
NearestNeighbors implements an algorithm for finding the k-nearest
neighbors to a query point within the set of points contained by a
KDTree instance. The algorithm can be specialized with a custom
distance-finding function by passing a Distance instance to its
constructor.
| Nested Class Summary | |
|---|---|
static interface |
NearestNeighbors.Entry<Coord extends java.lang.Number & java.lang.Comparable<? super Coord>,P extends Point<Coord>,V>
The Entry interface makes accessible the results of a NearestNeighbors search. |
| Constructor Summary | |
|---|---|
NearestNeighbors()
Constructs a NearestNeighbors instance using a EuclideanDistance
instance to calculate distances between points. |
|
NearestNeighbors(Distance<Coord,P> distance)
Constructs a new NearestNeighbors instance, using the specified distance-finding functor to calculate distances during searches. |
|
| Method Summary | |
|---|---|
NearestNeighbors.Entry<Coord,P,V>[] |
get(KDTree<Coord,P,V> tree,
P queryPoint,
int numNeighbors)
Same as get(tree, queryPoint, numNeighbors, true). |
NearestNeighbors.Entry<Coord,P,V>[] |
get(KDTree<Coord,P,V> tree,
P queryPoint,
int numNeighbors,
boolean omitQueryPoint)
Finds the k-nearest neighbors to a query point withina KDTree instance. |
void |
setDistance(Distance<Coord,P> distance)
Sets the distance-finding functor used to calculate distances during searches. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NearestNeighbors(Distance<Coord,P> distance)
distance - A distance-finding functor implementing
the Distance interface.public NearestNeighbors()
EuclideanDistance
instance to calculate distances between points.
| Method Detail |
|---|
public void setDistance(Distance<Coord,P> distance)
distance - The distance-finding functor to use for distance
calculations.
public NearestNeighbors.Entry<Coord,P,V>[] get(KDTree<Coord,P,V> tree,
P queryPoint,
int numNeighbors,
boolean omitQueryPoint)
NearestNeighbors.Entry instances, sorted
from nearest to farthest.
tree - The KDTree to search.queryPoint - The query point.numNeighbors - The number of nearest neighbors to find. This should
be a positive value. Non-positive values result in no neighbors
being found.omitQueryPoint - If true, point-value mappings at a distance of
zero are omitted from the result. If false, mappings at a
distance of zero are included.
public NearestNeighbors.Entry<Coord,P,V>[] get(KDTree<Coord,P,V> tree,
P queryPoint,
int numNeighbors)
get(tree, queryPoint, numNeighbors, true).
|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||