public class KdNode
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
KdNode.IKdValueFetcher
Interface for hyperplane coordinate value fetchers.
|
protected static class |
KdNode.KdValueFetcherX
Fetcher for the x-axis values.
|
protected static class |
KdNode.KdValueFetcherY
Fetcher for the x-axis values.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.List<ISpaceObject> |
content
List containing objects in leaf nodes, null otherwise.
|
protected KdNode.IKdValueFetcher |
fetcher
Value fetcher for fetching the correct coordinate on the splitting hyperplane.
|
protected double |
hyperplane
Coordinate for the splitting hyperplane.
|
protected KdNode |
left
Node for objects with coordinate below the splitting hyperplane, null for leaf nodes.
|
protected int |
maxLeafNodeSize
Default value for maximum number of objects in leaf nodes.
|
protected int |
maxMedianSamples
Default value for maximum number of samples taken to estimate coordinate median.
|
protected KdNode |
right
Node for objects with coordinate above the splitting hyperplane, null for leaf nodes.
|
Modifier | Constructor and Description |
---|---|
protected |
KdNode(java.util.List<ISpaceObject> input,
java.util.Random random)
Generates a new KdNode with the given input using default configuration.
|
protected |
KdNode(java.util.List<ISpaceObject> input,
java.util.Random random,
int maxLeafNodeSize,
int maxMedianSamples)
Generates a new KdNode with the given input.
|
protected |
KdNode(java.util.List<ISpaceObject> input,
java.util.Random random,
KdNode.IKdValueFetcher fetcher,
int maxLeafNodeSize,
int maxMedianSamples)
Generates a new KdNode with the given input.
|
Modifier and Type | Method and Description |
---|---|
protected double |
estimateMedian(java.util.List<ISpaceObject> input,
java.util.Random random,
KdNode.IKdValueFetcher fetcher)
Estimates the median value of the hyperplane coordinate of the input using random sampling.
|
protected static IVector2 |
getDistance(ISpaceObject obj,
IVector2 point) |
ISpaceObject |
getNearestObject(IVector2 point,
double radiusSquared)
Finds the object nearest to a given point within a search radius.
|
ISpaceObject |
getNearestObject(IVector2 point,
double radiusSquared,
IFilter filter)
Finds the object nearest to a given point within a search radius while filtering objects.
|
java.util.List<ISpaceObject> |
getNearestObjects(IVector2 point,
double radiusSquared,
IFilter filter)
Finds all objects within a given search radius.
|
protected static IVector2 |
getPosition(ISpaceObject obj) |
protected int maxLeafNodeSize
protected int maxMedianSamples
protected KdNode.IKdValueFetcher fetcher
protected KdNode left
protected KdNode right
protected double hyperplane
protected java.util.List<ISpaceObject> content
protected KdNode(java.util.List<ISpaceObject> input, java.util.Random random)
input
- The objects.random
- Source of randomness for median estimation sampling.protected KdNode(java.util.List<ISpaceObject> input, java.util.Random random, int maxLeafNodeSize, int maxMedianSamples)
input
- The objects.random
- Source of randomness for median estimation sampling.maxLeafNodeSize
- Maximum number of objects in leaf nodes.maxMedianSamples
- Maximum number of samples taken to estimate median for hyperplane.protected KdNode(java.util.List<ISpaceObject> input, java.util.Random random, KdNode.IKdValueFetcher fetcher, int maxLeafNodeSize, int maxMedianSamples)
input
- The objects.random
- Source of randomness for median estimation sampling.fetcher
- Value fetcher for the coordinate of the current hyperplane.maxLeafNodeSize
- Maximum number of objects in leaf nodes.maxMedianSamples
- Maximum number of samples taken to estimate median for hyperplane.public java.util.List<ISpaceObject> getNearestObjects(IVector2 point, double radiusSquared, IFilter filter)
point
- Center of the search area.radiusSquared
- Square of the search radius.filter
- Object filter.public ISpaceObject getNearestObject(IVector2 point, double radiusSquared)
point
- The point.radiusSquared
- The squared search radius.public ISpaceObject getNearestObject(IVector2 point, double radiusSquared, IFilter filter)
point
- The point.radiusSquared
- The squared search radius.filter
- Object filter.protected double estimateMedian(java.util.List<ISpaceObject> input, java.util.Random random, KdNode.IKdValueFetcher fetcher)
input
- The input objects.random
- A source of randomness for sampling.fetcher
- The value fetcher for the hyperplane coordinate.protected static final IVector2 getPosition(ISpaceObject obj)
protected static final IVector2 getDistance(ISpaceObject obj, IVector2 point)