Documentation
¶
Overview ¶
Package index provides spatial indices for 2-D points.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Circle ¶
Circle returns the indices of all points in the circle with the given center and radius.
func QuickSelect ¶
QuickSelect finds the kth smallest element in an unordered slice. It re-arranges the elements of data so that data[k] is the element that would be at position k if data were sorted, data[i] <= data[k] for i < k, and data[i] >= data[k] for i > k.
It implements the Quickselect algorithm (https://en.m.wikipedia.org/wiki/Quickselect).
Types ¶
type BasicKDTree ¶
type BasicKDTree struct {
// contains filtered or unexported fields
}
A BasicKDTree is a k-d tree for 2-D points that stores one point in each node.
func NewBasicKDTree ¶
func NewBasicKDTree(points [][2]float64) *BasicKDTree
NewBasicKDTree creates a BasicKDTree for the given points.
func (*BasicKDTree) BoundingBox ¶
func (t *BasicKDTree) BoundingBox(bb *geometry.BoundingBox) []int
BoundingBox returns the indices of all points within the given axis-aligned bounding box.
func (*BasicKDTree) Points ¶
func (t *BasicKDTree) Points() [][2]float64
Points returns the slice of points.
type Index ¶
type Index interface { // Points returns the slice of points. Points() [][2]float64 // BoundingBox returns the indices of all points within the given // axis-aligned bounding box. BoundingBox(bb *geometry.BoundingBox) []int }
An Index is a spatial index for a slice of points.
type KDTree8 ¶
type KDTree8 struct {
// contains filtered or unexported fields
}
A KDTree8 is a k-d tree for 2-D points that stores 8 points in each leaf node.
func NewKDTree8 ¶
NewKDTree8 creates a KDTree8 for the given points.
func (*KDTree8) BoundingBox ¶
func (t *KDTree8) BoundingBox(bb *geometry.BoundingBox) []int
BoundingBox returns the indices of all points within the given axis-aligned bounding box.
type LeafKDTree ¶
type LeafKDTree struct {
// contains filtered or unexported fields
}
A LeafKDTree is a k-d tree for 2-D points that stores one point in each leaf node.
func NewLeafKDTree ¶
func NewLeafKDTree(points [][2]float64) *LeafKDTree
NewLeafKDTree creates a LeafKDTree for the given points.
func (*LeafKDTree) BoundingBox ¶
func (t *LeafKDTree) BoundingBox(bb *geometry.BoundingBox) []int
BoundingBox returns the indices of all points within the given axis-aligned bounding box.
func (*LeafKDTree) Points ¶
func (t *LeafKDTree) Points() [][2]float64
Points returns the slice of points.
type TrivialIndex ¶
type TrivialIndex struct {
// contains filtered or unexported fields
}
A TrivialIndex is an implementation of Index that doesn't actually speed up any operations.
func NewTrivialIndex ¶
func NewTrivialIndex(points [][2]float64) *TrivialIndex
NewTrivialIndex returns a new TrivialIndex.
func (*TrivialIndex) BoundingBox ¶
func (i *TrivialIndex) BoundingBox(bb *geometry.BoundingBox) []int
BoundingBox returns the indices of all points within the given axis-aligned bounding box.
func (*TrivialIndex) Points ¶
func (i *TrivialIndex) Points() [][2]float64
Points returns the slice of points.