Documentation
¶
Overview ¶
Package kdtree implements a k-d tree data structure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewKDRange ¶
func NewKDRange(limits ...float64) kdrangeRange
NewKDRange creates a new Range.
It accepts a sequence of min/max pairs that define the Range. For example a 2-dimensional rectangle with the with 2 and height 3, starting at (1,2):
r := NewRange(1, 3, 2, 5)
I.e.:
x (dim 0): 1 <= x <= 3 y (dim 1): 2 <= y <= 5
Types ¶
type KDTree ¶
type KDTree struct {
// contains filtered or unexported fields
}
KDTree represents the 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) 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().
type Point ¶
type Point interface {
// Dimensions returns the total number of dimensions.
Dimensions() int
// Dimension returns the value of the i-th dimension.
Dimension(i int) float64
// Distance returns the distance between two points.
Distance(p Point) float64
// PlaneDistance returns the distance between the point and the plane X_{dim}=val.
PlaneDistance(val float64, dim int) float64
}
Point specifies one element of the k-d tree.
Click to show internal directories.
Click to hide internal directories.