Class JXG.Math.BoxQuadtree
↳ JXG.Math.BoxQuadtree
Defined in: bqdt.js.
Constructor Attributes | Constructor Name and Description |
---|---|
JXG.Math.BoxQuadtree(depth, capacity, bbox)
Instantiate a new box quadtree.
|
Field Attributes | Field Name and Description |
---|---|
<private> |
Bounding box [left, top, right, bottom].
|
<private> |
Capacity of the box quadtree node
|
<private> |
x-coordinate of bounding box center.
|
<private> |
y-coordinate of bounding box center.
|
<private> |
Maximum depth of the box quadtree node
|
<private> |
Item storage.
|
<private> |
In a subdivided quadtree this represents the top right subtree.
|
<private> |
In a subdivided quadtree this represents the top left subtree.
|
<private> |
In a subdivided quadtree this represents the bottom right subtree.
|
<private> |
In a subdivided quadtree this represents the bottom left subtree.
|
Method Attributes | Method Name and Description |
---|---|
Analyze the box quadtree.
|
|
find(box)
Find all entries of the box quadtree which have an overlap
with the given rectangle (AABB).
|
|
insert(items)
Insert an array of items into the box quadtree.
|
|
insertItem(it)
Insert an item into the box quadtree, where an item is an object
containing at least the properties
|
|
plot()
Generate data to plot the box quadtree as curve using updateDataArray.
|
|
<private> |
subdivide(nw_it, sw_it, ne_it, se_it, l, t, r, b)
Create the sub-quadrants if necessary, recursively
|
Class Detail
JXG.Math.BoxQuadtree(depth, capacity, bbox)
Instantiate a new box quadtree.
A box quadtree stores AABBs, i.e. axis-aligned bounding boxes.
The box quadtree has four sub-quadtress which maybe null if not needed.
- Parameters:
- {Number} depth
- Maximum recursion depth.
- {Number} capacity
- Maximum number of items stored in this node.
- {Array} bbox Optional
- Optional bounding box of the box quadtree. If not given, the bounding box is determined by the items in the insert method. This will only work correctly if the first call of insert contains the maximum bounding box.
Field Detail
<private>
{Array}
bbox
Bounding box [left, top, right, bottom].
<private>
{Number}
capacity
Capacity of the box quadtree node
<private>
{Number}
cx
x-coordinate of bounding box center.
<private>
{Number}
cy
y-coordinate of bounding box center.
<private>
{Number}
depth
Maximum depth of the box quadtree node
<private>
{Array}
items
Item storage.
<private>
{JXG.Math.BoxQuadtree}
northEast
In a subdivided quadtree this represents the top right subtree.
<private>
{JXG.Math.BoxQuadtree}
northWest
In a subdivided quadtree this represents the top left subtree.
<private>
{JXG.Math.BoxQuadtree}
southEast
In a subdivided quadtree this represents the bottom right subtree.
<private>
{JXG.Math.BoxQuadtree}
southWest
In a subdivided quadtree this represents the bottom left subtree.
Method Detail
{Object}
analyzeTree()
Analyze the box quadtree.
- Returns:
- {Object} data about the box quadtree
{Array}
find(box)
Find all entries of the box quadtree which have an overlap
with the given rectangle (AABB). Items may appear multiple times.
- Parameters:
- {Array} box
- AABB of the form [l, t, r, b]
- Returns:
- {Array} list of items overlapping with box
{Object}
insert(items)
Insert an array of items into the box quadtree. An item is an object
containing at least the properties
- xlb: lower bound on x
- xub: upper bound on x
- ylb: lower bound on y
- yub: upper bound on y
- Parameters:
- {Array} items
- to be inserted
- Returns:
- {Object} reference to the box quadtree
{Object}
insertItem(it)
Insert an item into the box quadtree, where an item is an object
containing at least the properties
- xlb: lower bound on x
- xub: upper bound on x
- ylb: lower bound on y
- yub: upper bound on y
- Parameters:
- {Object} it
- Item to be inserted
- Returns:
- {Object} reference to the box quadtree
{Array}
plot()
Generate data to plot the box quadtree as curve using updateDataArray.
- Returns:
- {Array} containing arrays dataX and dataY
- Examples:
// qdt contains a BoxQuadtree var qdtcurve = board.create('curve', [[], []], { strokeWidth: 1, strokeColor: '#0000ff', strokeOpacity: 0.3 }); qdtcurve.updateDataArray = function () { var ret = qdt.plot(); this.dataX = ret[0]; this.dataY = ret[1]; console.log(qdt.analyzeTree()); }; board.update();
<private>
{Object}
subdivide(nw_it, sw_it, ne_it, se_it, l, t, r, b)
Create the sub-quadrants if necessary, recursively
- Parameters:
- {Array} nw_it
- list of items for northWest subtree
- {Array} sw_it
- list of items for southWest subtree
- {Array} ne_it
- list of items for northEast subtree
- {Array} se_it
- list of items for southEast subtree
- {Number} l
- bounding box left
- {Number} t
- bounding box top
- {Number} r
- bounding box right
- {Number} b
- bounding box bottom
- Returns:
- {Object} reference to the box quadtree