public class IncrementalShortKDTree extends Object
short[]
s. Includes
support for range search, neighbour search, and radius search. The tree created
by this class will usually be rather unbalanced.
The KDTree allows fast search for points in relatively low-dimension spaces.
Constructor and Description |
---|
IncrementalShortKDTree()
Create an empty KDTree object
|
IncrementalShortKDTree(Collection<short[]> coords)
Create a KDTree object and populate it with the given data.
|
IncrementalShortKDTree(short[][] coords)
Create a KDTree object and populate it with the given data.
|
Modifier and Type | Method and Description |
---|---|
protected static double |
distance(short[] a,
short[] b) |
ObjectDoublePair<short[]> |
findNearestNeighbour(short[] query)
Find the nearest neighbour.
|
List<ObjectDoublePair<short[]>> |
findNearestNeighbours(short[] query,
int k)
Find the K nearest neighbours.
|
void |
insert(short[] point)
Inserts a point into the tree, preserving the spatial ordering.
|
void |
insertAll(Collection<short[]> coords)
Insert all the points from the given collection into the index.
|
void |
insertAll(short[][] coords)
Insert all the points from the given collection into the index.
|
List<ObjectDoublePair<short[]>> |
radiusDistanceSearch(short[] centre,
short radius)
Find all the points within the given radius of the given point.
|
List<short[]> |
radiusSearch(short[] centre,
short radius)
Find all the points within the given radius of the given point
|
List<short[]> |
rangeSearch(short[] lowerExtreme,
short[] upperExtreme)
Searches the tree for all points contained within the bounding box
defined by the given upper and lower extremes
|
public IncrementalShortKDTree()
public IncrementalShortKDTree(Collection<short[]> coords)
coords
- the data to populate the index with.public IncrementalShortKDTree(short[][] coords)
coords
- the data to populate the index with.public void insertAll(Collection<short[]> coords)
coords
- The points to add.public void insertAll(short[][] coords)
coords
- The points to add.public void insert(short[] point)
point
- Point to insert.public List<short[]> rangeSearch(short[] lowerExtreme, short[] upperExtreme)
lowerExtreme
- upperExtreme
- protected static final double distance(short[] a, short[] b)
public ObjectDoublePair<short[]> findNearestNeighbour(short[] query)
query
- query coordinatepublic List<ObjectDoublePair<short[]>> findNearestNeighbours(short[] query, int k)
query
- query coordinatek
- the number of neighbours to findpublic List<short[]> radiusSearch(short[] centre, short radius)
centre
- the centre pointradius
- the radiuspublic List<ObjectDoublePair<short[]>> radiusDistanceSearch(short[] centre, short radius)
centre
- the centre pointradius
- the radius