public class KdTree extends Object
Constructor and Description |
---|
KdTree()
Generates an empty KdTree using default configuration.
|
KdTree(int maxLeafNodeSize,
int maxMedianSamples)
Generates an empty KdTree.
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(ISpaceObject obj)
Adds an object to the tree.
|
ISpaceObject |
getNearestObject(IVector2 point)
Finds an object closest to the given point (exhaustive search!).
|
ISpaceObject |
getNearestObject(IVector2 point,
double searchRadius)
Finds an object closest to the given point with a given search radius.
|
ISpaceObject |
getNearestObject(IVector2 point,
double searchRadius,
IFilter filter)
Finds an object closest to the given point with a given search radius,
while filtering objects.
|
ISpaceObject |
getNearestObject(IVector2 point,
IFilter filter)
Finds an object closest to the given point while filtering objects (exhaustive search!).
|
List<ISpaceObject> |
getNearestObjects(IVector2 point,
double radius)
Finds all objects within a given search radius.
|
List<ISpaceObject> |
getNearestObjects(IVector2 point,
double radius,
IFilter filter)
Finds all objects within a given search radius.
|
void |
rebuild()
Rebuilds the tree, updating spatial information, adding objects and removing objects.
|
void |
removeObject(ISpaceObject obj)
Removes an object to the tree.
|
public KdTree()
public KdTree(int maxLeafNodeSize, int maxMedianSamples)
maxLeafNodeSize
- Maximum number of objects in leaf nodes.maxMedianSamples
- Maximum number of samples taken to estimate coordinate median.public List<ISpaceObject> getNearestObjects(IVector2 point, double radius)
point
- Center of the search area.radius
- The search radius.public List<ISpaceObject> getNearestObjects(IVector2 point, double radius, IFilter filter)
point
- Center of the search area.radius
- The search radius.filter
- Object filter.public ISpaceObject getNearestObject(IVector2 point)
point
- The point.public ISpaceObject getNearestObject(IVector2 point, IFilter filter)
point
- The point.filter
- Object filter.public ISpaceObject getNearestObject(IVector2 point, double searchRadius)
point
- The point.searchRadius
- The search radius.public ISpaceObject getNearestObject(IVector2 point, double searchRadius, IFilter filter)
point
- The point.searchRadius
- The search radius.filter
- Object filter.public void addObject(ISpaceObject obj)
obj
- The object being added.public void removeObject(ISpaceObject obj)
obj
- The object being removed.public void rebuild()
Copyright © 2012. All Rights Reserved.