Documentation ¶
Overview ¶
Package kdtree implements a k-d tree data structure.
Index ¶
- func EuclideanDistance(p1, p2 Point) float64
- type DistanceFunc
- type KDTree
- func (t *KDTree) Balance()
- func (t *KDTree) Insert(p Point)
- func (t *KDTree) KNN(p Point, k int) []Point
- func (t *KDTree) LineTrace(start Point, end Point, radius float64) (*Point, float64)
- func (t *KDTree) Points() []Point
- func (t *KDTree) RangeSearch(r kdrange.Range) []Point
- func (t *KDTree) Remove(p Point) Point
- func (t *KDTree) String() string
- type Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EuclideanDistance ¶
Types ¶
type DistanceFunc ¶
Used for different distance functions (manhattan, euclidean, etc.)
type KDTree ¶
type KDTree struct {
// contains filtered or unexported fields
}
KDTree represents the k-d tree.
func NewCustom ¶
func NewCustom(points []Point, distance DistanceFunc) *KDTree
New returns a balanced k-d tree.
func (*KDTree) Balance ¶
func (t *KDTree) Balance()
Balance rebalances the k-d tree by recreating it.
func (*KDTree) KNN ¶
KNN returns the k-nearest neighbours of the given point. The points are sorted by the distance to the given points. Starting with the nearest.
func (*KDTree) LineTrace ¶ added in v0.0.1
RayTrace returns the first point (with the radius) that intersects this LineSegment from start to end and the dist-factor from [0,1], or "max float" if no hit
func (*KDTree) RangeSearch ¶
RangeSearch returns all points in the given range r.
Returns an empty slice when input is nil or len(r) does not equal Point.Dimensions().
Directories ¶
Path | Synopsis |
---|---|
Package kdrange contains k-dimensional range struct and helpers.
|
Package kdrange contains k-dimensional range struct and helpers. |
Package points contains multiple example implementations of the kdtree.Point interface.
|
Package points contains multiple example implementations of the kdtree.Point interface. |