rtree

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMinRTreeOption = 25
	DefaultMaxRTreeOption = 50
)

RTree options

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity interface {
	GetID() uint32
}

Entity return GetID

type Moveable

type Moveable interface {
	shapes.Spatial
	UpdateSpatial(s shapes.Spatial)
}

Moveable objects what ability to update themself

type RTree

type RTree struct {
	MinChildren int
	MaxChildren int
	// contains filtered or unexported fields
}

RTree represents an R-tree, a balanced search tree for storing and querying shapes.Spatial objects

func NewRTree

func NewRTree(min, max int) *RTree

NewRTree returns an RTree. If the number of objects given on initialization is larger than max, the RTree will be initialized using the Overlap Minimizing Top-down bulk-loading algorithm.

func (*RTree) Collision

func (r *RTree) Collision(obj shapes.Spatial, filter func(spatial shapes.Spatial) bool) (objects []shapes.Spatial)

Collision check shapes.Spatial object on collisions

func (*RTree) Delete

func (r *RTree) Delete(obj shapes.Spatial) bool

Delete removes an object from the tree

func (*RTree) Depth

func (r *RTree) Depth() int

Depth returns the maximum depth of tree.

func (*RTree) GetAllBoundingBoxes

func (r *RTree) GetAllBoundingBoxes() []shapes.Box

GetAllBoundingBoxes returning slice of bounding boxes by traversing tree.

func (*RTree) Insert

func (r *RTree) Insert(obj shapes.Spatial)

Insert implemented per Section 3.2 of "R-trees: A Dynamic Index Structure for shapes.Spatial Searching" by A. Guttman, Proceedings of ACM SIGMOD, p. 47-57, 1984.

func (*RTree) MoveObject

func (r *RTree) MoveObject(obj Moveable, v shapes.Point)

MoveObject move object

func (*RTree) NearestNeighbor

func (r *RTree) NearestNeighbor(p shapes.Point, filter func(spatial shapes.Spatial) bool) (shapes.Spatial, float64)

NearestNeighbor returns the closest object to the specified point

func (*RTree) NearestNeighbors

func (r *RTree) NearestNeighbors(k int, p shapes.Point,
	maxDistance float64, filter func(spatial shapes.Spatial) bool,
) ([]shapes.Spatial, []float64)

NearestNeighbors gets the closest Spatials to the Point.

func (*RTree) SearchIntersect

func (r *RTree) SearchIntersect(bb shapes.Box, filter func(spatial shapes.Spatial) bool) []shapes.Spatial

SearchIntersect returns all objects that intersect the specified rectangle.

func (*RTree) Size

func (r *RTree) Size() int

Size returns the number of objects currently stored in tree.

func (*RTree) Update

func (r *RTree) Update(obj shapes.Spatial)

Update delete and insert object

Jump to

Keyboard shortcuts

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