ngraph.quadtreebh
Version:
Quad tree data structure for Barnes-Hut simulation
31 lines (26 loc) • 636 B
JavaScript
/**
* Internal data structure to represent 2D QuadTree node
*/
module.exports = function Node() {
// body stored inside this node. In quad tree only leaf nodes (by construction)
// contain boides:
this.body = null;
// Child nodes are stored in quads. Each quad is presented by number:
// 0 | 1
// -----
// 2 | 3
this.quad0 = null;
this.quad1 = null;
this.quad2 = null;
this.quad3 = null;
// Total mass of current node
this.mass = 0;
// Center of mass coordinates
this.massX = 0;
this.massY = 0;
// bounding box coordinates
this.left = 0;
this.top = 0;
this.bottom = 0;
this.right = 0;
};