Class KdTree
- java.lang.Object
- 
- jadex.extension.envsupport.environment.space2d.KdTree
 
- 
 public class KdTree extends java.lang.ObjectImplementation of a 2D variant of a k-dimensional-tree for spatial separation and searches.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static intDEFAULT_MAX_LEAF_NODE_SIZEDefault value for maximum number of objects in leaf nodes.protected static intDEFAULT_MAX_MEDIAN_SAMPLESDefault value for maximum number of samples taken to estimate coordinate median.protected intmaxLeafNodeSizeMaximum number of objects in leaf nodes.protected intmaxMedianSamplesMaximum number of samples taken to estimate coordinate median.protected java.util.RandomrandomRandom for picking object samples for estimating median.protected KdNoderootNodeThe root node.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(ISpaceObject obj)Adds an object to the tree.ISpaceObjectgetNearestObject(IVector2 point)Finds an object closest to the given point (exhaustive search!).ISpaceObjectgetNearestObject(IVector2 point, double searchRadius)Finds an object closest to the given point with a given search radius.ISpaceObjectgetNearestObject(IVector2 point, double searchRadius, IFilter filter)Finds an object closest to the given point with a given search radius, while filtering objects.ISpaceObjectgetNearestObject(IVector2 point, IFilter filter)Finds an object closest to the given point while filtering objects (exhaustive search!).java.util.List<ISpaceObject>getNearestObjects(IVector2 point, double radius)Finds all objects within a given search radius.java.util.List<ISpaceObject>getNearestObjects(IVector2 point, double radius, IFilter filter)Finds all objects within a given search radius.voidrebuild()Rebuilds the tree, updating spatial information, adding objects and removing objects.voidremoveObject(ISpaceObject obj)Removes an object to the tree.
 
- 
- 
- 
Field Detail- 
DEFAULT_MAX_LEAF_NODE_SIZEprotected static final int DEFAULT_MAX_LEAF_NODE_SIZE Default value for maximum number of objects in leaf nodes.- See Also:
- Constant Field Values
 
 - 
DEFAULT_MAX_MEDIAN_SAMPLESprotected static final int DEFAULT_MAX_MEDIAN_SAMPLES Default value for maximum number of samples taken to estimate coordinate median.- See Also:
- Constant Field Values
 
 - 
rootNodeprotected KdNode rootNode The root node.
 - 
randomprotected java.util.Random random Random for picking object samples for estimating median.
 - 
maxLeafNodeSizeprotected int maxLeafNodeSize Maximum number of objects in leaf nodes.
 - 
maxMedianSamplesprotected int maxMedianSamples Maximum number of samples taken to estimate coordinate median.
 
- 
 - 
Constructor Detail- 
KdTreepublic KdTree() Generates an empty KdTree using default configuration.
 - 
KdTreepublic KdTree(int maxLeafNodeSize, int maxMedianSamples)Generates an empty KdTree.- Parameters:
- maxLeafNodeSize- Maximum number of objects in leaf nodes.
- maxMedianSamples- Maximum number of samples taken to estimate coordinate median.
 
 
- 
 - 
Method Detail- 
getNearestObjectspublic java.util.List<ISpaceObject> getNearestObjects(IVector2 point, double radius) Finds all objects within a given search radius.- Parameters:
- point- Center of the search area.
- radius- The search radius.
 
 - 
getNearestObjectspublic java.util.List<ISpaceObject> getNearestObjects(IVector2 point, double radius, IFilter filter) Finds all objects within a given search radius.- Parameters:
- point- Center of the search area.
- radius- The search radius.
- filter- Object filter.
 
 - 
getNearestObjectpublic ISpaceObject getNearestObject(IVector2 point) Finds an object closest to the given point (exhaustive search!).- Parameters:
- point- The point.
- Returns:
- Object closest to the point.
 
 - 
getNearestObjectpublic ISpaceObject getNearestObject(IVector2 point, IFilter filter) Finds an object closest to the given point while filtering objects (exhaustive search!).- Parameters:
- point- The point.
- filter- Object filter.
- Returns:
- Object closest to the point.
 
 - 
getNearestObjectpublic ISpaceObject getNearestObject(IVector2 point, double searchRadius) Finds an object closest to the given point with a given search radius.- Parameters:
- point- The point.
- searchRadius- The search radius.
- Returns:
- Object closest to the point.
 
 - 
getNearestObjectpublic ISpaceObject getNearestObject(IVector2 point, double searchRadius, IFilter filter) Finds an object closest to the given point with a given search radius, while filtering objects.- Parameters:
- point- The point.
- searchRadius- The search radius.
- filter- Object filter.
- Returns:
- Object closest to the point.
 
 - 
addObjectpublic void addObject(ISpaceObject obj) Adds an object to the tree. The object will not become visible until rebuild() is called.- Parameters:
- obj- The object being added.
 
 - 
removeObjectpublic void removeObject(ISpaceObject obj) Removes an object to the tree. The object will not vanish until rebuild() is called.- Parameters:
- obj- The object being removed.
 
 - 
rebuildpublic void rebuild() Rebuilds the tree, updating spatial information, adding objects and removing objects.
 
- 
 
-