index

package
v0.0.0-...-a9d970f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2018 License: MIT Imports: 5 Imported by: 1

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

func Circle(i Index, c [2]float64, r float64) []int

Circle returns the indices of all points in the circle with the given center and radius.

func QuickSelect

func QuickSelect(data sort.Interface, k int)

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

func NewKDTree8(points [][2]float64) *KDTree8

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.

func (*KDTree8) Points

func (t *KDTree8) Points() [][2]float64

Points returns the slice of points.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL