The Cuik KD-Tree Library
cuik-kdtree.c File ReferenceImplementation of a kd-tree. More... #include "cuik-kdtree.h" #include "definitions.h" #include "vector.h" #include "random.h" #include "assert.h"
Include dependency graph for cuik-kdtree.c:
Go to the source code of this file.
Detailed DescriptionImplementation of a kd-tree. This is used to speed up the search of nearest neighbours (or neighbours in a given ball) but also for sampling. This is an alternative to the DNN library, but here we use the kd-tree not only to search but also to sample. The DNN kd-tree is actually a forest of trees. To samle a single tree is necessary. So,instead of modifying the DNN implementation, we implemented a new kd-tree, even at the risk of being less efficient (specially when searching for neighbours). This implemetation follows the paper
Definition in file cuik-kdtree.c. Define Documentation
If set to 1, the split point when building the kd-tree is computing using the median. Otherwise, we use the mean as an approximation to the median. Using the median is supposed to produce more balanced trees. Definition at line 42 of file cuik-kdtree.c. Function Documentation
Kd-tree constructor.
Definition at line 101 of file cuik-kdtree.c. References TKDtree::ambient, TKDtree::boundingBox, CopyRectangle(), EnlargeRectangleWithLimits(), ExpandRectangle(), FALSE, GetRectangleDim(), GetRectangleLimits(), GetRectangleSplitDim(), TKDtree::height, TKDtree::id, INF, InitRectangleFromPoint(), TKDtree::isLeaf, KDTPTR, TKDtree::left, TKDtree::leftLeaf, TKDtree::m, TKDtree::n, TKDtree::nd, NEW, TKDtree::nextLeaf, NO_UINT, TKDtree::p, TKDtree::r, TKDtree::right, TKDtree::rightLeaf, TKDtree::samplingArea, SetRectangleLimits(), SetRectangleLowerLimit(), SetRectangleUpperLimit(), TKDtree::splitDim, TKDtree::splitValue, SWAP, TRUE, and TKDtree::volume. Referenced by AddPoint2KDtree(), and InitKDTree().
Here is the call graph for this function:
Here is the caller graph for this function:
Auxiliary funciton for NearestNeighbour.
Definition at line 312 of file cuik-kdtree.c. References TKDtree::ambient, TKDtree::boundingBox, TKDtree::id, TKDtree::isLeaf, KDTPTR, TKDtree::left, TKDtree::n, TKDtree::nd, TKDtree::p, TKDtree::right, TKDtree::splitDim, SquaredDistanceToRectangle(), SquaredDistanceToRectangleDimension(), and VectorSquaredDistanceTopologyMin(). Referenced by NearestNeighbour().
Here is the call graph for this function:
Here is the caller graph for this function:
Auxiliary funciton for NeighboursInBall.
Definition at line 369 of file cuik-kdtree.c. References TKDtree::ambient, TKDtree::boundingBox, TKDtree::id, TKDtree::isLeaf, KDTPTR, TKDtree::left, MEM_DUP, TKDtree::n, TKDtree::nd, TKDtree::p, TKDtree::right, TKDtree::splitDim, SquaredDistanceToRectangle(), SquaredDistanceToRectangleDimension(), and VectorSquaredDistanceTopologyMin(). Referenced by NeighboursInBall().
Here is the call graph for this function:
Here is the caller graph for this function:
Kd-tree constructor.
Definition at line 418 of file cuik-kdtree.c. References BuildKDTree(). Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
Adds a point to a kd-tree.
Definition at line 427 of file cuik-kdtree.c. References AddPoint2KDtree(), TKDtree::ambient, TKDtree::boundingBox, BuildKDTree(), DeleteKDtree(), EnlargeRectangleWithLimits(), ExpandRectangle(), TKDtree::height, TKDtree::id, InitRectangleFromPoint(), TKDtree::isLeaf, KDTPTR, TKDtree::left, TKDtree::leftLeaf, TKDtree::m, TKDtree::n, TKDtree::nd, NEW, TKDtree::nextLeaf, TKDtree::p, TKDtree::r, TKDtree::right, TKDtree::rightLeaf, TKDtree::samplingArea, TKDtree::splitDim, TKDtree::splitValue, and TKDtree::volume. Referenced by AddPoint2KDtree(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:
Uses the kd-tree to find the nearest-neighbour of a given point.
Definition at line 539 of file cuik-kdtree.c. References INF, TKDtree::n, NO_UINT, and SearchKDtree(). Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
Determines all the points in a given ball.
Definition at line 555 of file cuik-kdtree.c. References TKDtree::n, NEW, and SearchInBallKDtree(). Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
Geneates a random sample in the volume covered by the kd-tree expanded by a given factor ('r' given in the kd-tree construction) with uniform distribution.
Definition at line 572 of file cuik-kdtree.c. References TKDtree::isLeaf, KDTPTR, TKDtree::left, randomDouble(), RandomPointInRectangle(), TKDtree::right, SampleInKDtree(), TKDtree::samplingArea, and TKDtree::volume. Referenced by SampleInKDtree().
Here is the call graph for this function:
Here is the caller graph for this function:
Destructor Definition at line 589 of file cuik-kdtree.c. References TKDtree::ambient, TKDtree::boundingBox, DeleteKDtree(), DeleteRectangle(), TKDtree::id, TKDtree::isLeaf, KDTPTR, TKDtree::left, TKDtree::p, TKDtree::right, and TKDtree::samplingArea. Referenced by AddPoint2KDtree(), DeleteKDtree(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
Follow us!