Class: Quadtree

Quadtree

new Quadtree(options)

Quadtree contstructor function. Use to initialize the Quadtree. Also, whenever the quadtree splits, this constructor is used to initialize the new nodes of the quadtree.
Parameters:
Name Type Description
options Object The only options of concern to you: width, height, maxChildren, depth
Source:

Methods

canCollapse()

Helper method that determines if the quadtree should collapse
Source:

collapse()

Collapses the quadTree
Source:

divide()

Partitions the quadTree into 4 equal sized quadTrees. It also re-inserts all of the children that the leaf contained.
Source:

getChildCount() → {Number}

Returns the number of children in the quadTree
Source:
Returns:
The number of children in the quadTree
Type
Number

getChildren() → {Array}

getChildren returns an array of all the children of the quadTree
Source:
Returns:
all the children of the quadTree
Type
Array

getOrphanAndChildCount() → {Number}

getOrphanAndChildCount returns all rectangles that have been inserted into the quadtree
Source:
Returns:
The number of all inserted objects in the quadtree
Type
Number

getOrphanCount() → {Array}

getOrphanCount returns the number of orphans in the quadTree
Source:
Returns:
number of orphans in the quadTree
Type
Array

getOrphans() → {Array}

getOrphans return all the orphans of the quadTree
Source:
Returns:
all the orphans of the quadTree
Type
Array

getOrphansAndChildren() → {Array}

getOrphansAndChildren returns an array of all the children and orphans of the quadTree
Source:
Returns:
all the children and orphans of the quadTree
Type
Array

getQuadtreeCount() → {Number}

getQuadtreeCount returns the number of divisions within the quadtree.
Source:
Returns:
The number of divisions within the quadtree.
Type
Number

insert(An)

Inserts an object into the quadTree
Parameters:
Name Type Description
An Object arbitrary object with rectangle properties (x, y, width, height)
Source: