TSlackTree¶
A 2D version of a KDTree for TPoint datatype
Note: For more dimensions, and/or floating point values, along with category or index reference see TKDTree.
TSlackTree.Init¶
procedure TSlackTree.Init(TPA: TPointArray);
Builds the KDTree.
Time complexity average is O(n log n)
TSlackTree.IndexOf¶
function TSlackTree.IndexOf(P: TPoint): Integer;
Search and find the index for use in TSlackTree.Data for a given point p
Time complexity average is O(log n)
TSlackTree.Find¶
function TSlackTree.Find(P: TPoint): PSlackNode;
Search and find the given point p
, returns a node, a pointer to the tree node.
Time complexity average is O(log n)
TSlackTree.Hide¶
procedure TSlackTree.Hide(idx:Integer);
Hide the node (by index) so that queries will not return it.
Time complexity average is O(1)
TSlackTree.Hide¶
function TSlackTree.Hide(P: TPoint): Boolean; overload;
Hide the node (by TPoint) so that queries will not return it.
Time complexity average is O(log n)
TSlackTree.RawNearest¶
function TSlackTree.RawNearest(P: TPoint; NotEqual: Boolean = False): PSlackNode;
Returns the closest node to the point given.
Time complexity average is O(log n)
TSlackTree.Nearest¶
function TSlackTree.Nearest(P: TPoint; NotEqual :Boolean = False): TPoint;
Returns the closest point to the point given.
Time complexity average is O(log n)
TSlackTree.RawKNearest¶
function TSlackTree.RawKNearest(P: TPoint; k:Integer; NotEqual: Boolean = False): TSlackRefArray;
Returns the k closest node to the point given.
Time complexity average is O(k * log n)
TSlackTree.KNearest¶
function TSlackTree.KNearest(P: TPoint; k:Integer; NotEqual: Boolean = False): TPointArray;
Returns the k closest points to the point given.
Time complexity average is O(k * log n)
TSlackTree.RawRangeQuery¶
function TSlackTree.RawRangeQuery(B:TBox): TSlackRefArray;
TSlackTree.RangeQuery¶
function TSlackTree.RangeQuery(B:TBox; hide:Boolean = False): TPointArray;
Returns all the points that are within the given box.
Time complexity average is O(k * log n) where k is the number of points returned
TSlackTree.RangeQueryEx¶
function TSlackTree.RangeQueryEx(query:TPoint; xRad,yRad:Double; hide: Boolean = False): TPointArray;
Returns all the points that are within the given range xRad and yRad.
Time complexity average is O(k * log n) where k is the number of points returned
TSlackTree.RangeQueryEx¶
function TSlackTree.RangeQueryEx(query:TPoint; xmin,ymin,xmax,ymax: Double; hide: Boolean = False): TPointArray;
Returns all the points that are further away than xmin, and ymin, but closer than xmax, and ymax from the query.
Time complexity average is O(k * log n) where k is the number of points returned
TSlackTree.Clusters¶
function TSlackTree.Clusters(xRad,yRad: Single): T2DPointArray;
Like TPA.Cluster, but acts on the points in the tree, and allows you to use floats for xRad, and yRad. This methods also exists in TKDTree and works in n dimensions.
Time complexity average is between O(n) and O(n log n)
Speedwise, once the tree is built this method is on pair with ClusterTPA.
TSlackTree.RefArray¶
function TSlackTree.RefArray: TSlackRefArray;