Quadtree

Class representing a quadtree.

This implementation is adapted from CodingTrain/QuadTree, which is licensed under an MIT License.

Constructor

new Quadtree(boundary, capacity)

Create a quadtree.

Parameters:
NameTypeDescription
boundaryAABB

The bounding box of the quadtree.

capacitynumber

The number of points that can be inserted into Quadtree without subdividing.

Classes

Quadtree

Methods

insert(point)

Add a point into this quadtree.

Parameters:
NameTypeDescription
pointVector

query(range) → {Array.<Vector>}

Check for points in a given range and return them in an array.

Parameters:
NameTypeDescription
rangeAABB

The bounding box of the query.

Returns:
Type: 
Array.<Vector>

show(plot)

For each boundary of this quadtree and all it's children, create Lines from those rectangles and add them to a Plot.

Parameters:
NameTypeDescription
plotPlot