ngraph.quadtreebh3d
Version:
Quad Tree data structure for Barnes-Hut simulation in 3d space
43 lines (38 loc) • 855 B
JavaScript
/**
* Internal data structure to represent 3D 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:
// Behind Z median:
// 0 | 1
// -----
// 2 | 3
// In front of Z median:
// 4 | 5
// -----
// 6 | 7
this.quad0 = null;
this.quad1 = null;
this.quad2 = null;
this.quad3 = null;
this.quad4 = null;
this.quad5 = null;
this.quad6 = null;
this.quad7 = null;
// Total mass of current node
this.mass = 0;
// Center of mass coordinates
this.massX = 0;
this.massY = 0;
this.massZ = 0;
// bounding box coordinates
this.left = 0;
this.top = 0;
this.bottom = 0;
this.right = 0;
this.front = 0;
this.back = 0;
};