quadtree

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Via https://github.com/JamesLMilner/quadtree-go Converted to ints for our use case

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bounds

type Bounds struct {
	X, Y, Width, Height int
	Value               interface{}
}

Bounds - A bounding box with a x,y origin and width and height

func (*Bounds) Intersects

func (b *Bounds) Intersects(a Bounds) bool

Intersects - Checks if a Bounds object intersects with another Bounds

func (*Bounds) IsPoint

func (b *Bounds) IsPoint() bool

IsPoint - Checks if a bounds object is a point or not (has no width or height)

type Quadtree

type Quadtree struct {
	Bounds     Bounds
	MaxObjects int // Maximum objects a node can hold before splitting into 4 subnodes
	MaxLevels  int // Total max levels inside root Quadtree
	Level      int // Depth level, required for subnodes
	Objects    []Bounds
	Nodes      []Quadtree
	Total      int
}

Quadtree - The quadtree data structure

func (*Quadtree) Clear

func (qt *Quadtree) Clear()

Clear - Clear the Quadtree

func (*Quadtree) Insert

func (qt *Quadtree) Insert(pRect Bounds)

Insert - Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.

func (*Quadtree) Retrieve

func (qt *Quadtree) Retrieve(pRect Bounds) []Bounds

Retrieve - Return all objects that could collide with the given object

func (*Quadtree) RetrieveIntersections

func (qt *Quadtree) RetrieveIntersections(find Bounds) []Bounds

RetrieveIntersections - Bring back all the bounds in a Quadtree that intersect with a provided bounds

func (*Quadtree) RetrievePoints

func (qt *Quadtree) RetrievePoints(find Bounds) []Bounds

RetrievePoints - Return all points that collide

func (*Quadtree) TotalNodes

func (qt *Quadtree) TotalNodes() int

TotalNodes - Retrieve the total number of sub-Quadtrees in a Quadtree

Jump to

Keyboard shortcuts

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