Documentation ¶
Index ¶
- Variables
- type Bounds
- type Circle
- type Item
- type Quadtree
- func (qt *Quadtree) Clear()
- func (qt *Quadtree) Insert(pRect Bounds) (q *Quadtree)
- func (qt *Quadtree) RemoveItem(item Item)
- func (qt *Quadtree) Retrieve(pRect Bounds) []Bounds
- func (qt *Quadtree) RetrieveIntersections(find Bounds) []Bounds
- func (qt *Quadtree) RetrievePoints(find Bounds) []Bounds
- func (qt *Quadtree) TotalNodes() int
- type RTree
- func (rt *RTree) AddItem(item Item) error
- func (r *RTree) AddTree(l *RTree) error
- func (rt *RTree) Contains(item Item) *RTree
- func (r RTree) Distance(p r2.Point) float64
- func (rt *RTree) Find(condition func(tree *RTree) bool) []RTree
- func (rt *RTree) InRange(location r2.Point, max_range float64) []*RTree
- func (rt RTree) Level() int
- func (rt *RTree) Nearest(location r2.Point, max_range float64) *RTree
- func (rt *RTree) RemoveItem(item Item)
- func (rt *RTree) UpdateRect()
Constants ¶
This section is empty.
Variables ¶
var MaxRange float64 = 4.0
MaxRange is using for automatically adding the new node in AddItem
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
Bounds - A bounding box with a x,y origin and width and height
func (*Bounds) Intersects ¶
Intersects - Checks if a Bounds object intersects with another Bounds
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) Insert ¶
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) RemoveItem ¶ added in v1.1.1
func (*Quadtree) RetrieveIntersections ¶
RetrieveIntersections - Bring back all the bounds in a Quadtree that intersect with a provided bounds
func (*Quadtree) RetrievePoints ¶
RetrievePoints - Return all points that collide
func (*Quadtree) TotalNodes ¶
TotalNodes - Retrieve the total number of sub-Quadtrees in a Quadtree
type RTree ¶
type RTree struct { Ancestor *RTree Descendant []*RTree Items []Item Rect r2.Rect MaxItem int // contains filtered or unexported fields }
RTree representation a tree for spatial indexing which improve the time for searching a location in space
func (*RTree) AddItem ¶
The AddItem adds a new item to the tree. automatically create new RTree to hold this item if these are no RTree near the item in MaxRange AddItem helps to automatically scale the tree and find the right tree for grouping
func (*RTree) AddTree ¶
AddTree new RTree to current Tree, the left tree will be descendant of the right tree and the right tree will be the ancestor of the left tree. An error will be returned in case the left tree is nil or the left tree is already been the descendant of the right.
func (*RTree) Contains ¶
Find the Tree which is holding finding item The smallest tree will be returned if found otherwise the return value will be nil
func (RTree) Distance ¶
Get the distance between two RTree Location is measure by center of two RTree
func (*RTree) InRange ¶
InRange find trees which are not further than the max range with the location Items in the tree are potential to be the item in the range
func (*RTree) Nearest ¶
Nearest find the nearest RTree in Descendant which is in max_range from the location nil will be returned if there are no RTree
func (*RTree) RemoveItem ¶ added in v1.1.3
func (*RTree) UpdateRect ¶
func (rt *RTree) UpdateRect()
UpdateRect modify the Rect the size and affect to the Rect of Ancestor UpdateRect should be used for automatically updating size of Rect