ngraph.quadtreebh3d
Advanced tools
Comparing version 0.0.1 to 0.0.2
10
index.js
@@ -181,6 +181,4 @@ /** | ||
shiftIdx += 1; | ||
// technically there should be external "if (body !== sourceBody) {" | ||
// but in practice it gives slightghly worse performance, and does not | ||
// have impact on layout correctness | ||
if (body && body !== sourceBody) { | ||
var differentBody = (body !== sourceBody); | ||
if (body && differentBody) { | ||
// If the current node is a leaf node (and it is not source body), | ||
@@ -208,3 +206,3 @@ // calculate the force exerted by the current node on body, and add this | ||
fz += v * dz; | ||
} else { | ||
} else if (differentBody) { | ||
// Otherwise, calculate the ratio s / r, where s is the width of the region | ||
@@ -216,2 +214,3 @@ // represented by the internal node, and r is the distance between the body | ||
dz = node.massZ / node.mass - sourceBody.pos.z; | ||
r = Math.sqrt(dx * dx + dy * dy + dz * dz); | ||
@@ -227,2 +226,3 @@ | ||
} | ||
// If s / r < θ, treat this internal node as a single body, and calculate the | ||
@@ -229,0 +229,0 @@ // force it exerts on sourceBody, and add this amount to sourceBody's net force. |
@@ -26,2 +26,3 @@ /** | ||
this.massY = 0; | ||
this.massZ = 0; | ||
@@ -28,0 +29,0 @@ // bounding box coordinates |
{ | ||
"name": "ngraph.quadtreebh3d", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Quad Tree data structure for Barnes-Hut simulation in 3d space", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,3 +0,4 @@ | ||
Bodies #1000 | ||
Theta 1.2 x 4.43 ops/sec ±1.46% (15 runs sampled) | ||
Theta 0.8 x 4.16 ops/sec ±7.39% (15 runs sampled) | ||
Bodies #10000 | ||
Theta 1.2 x 8.87 ops/sec ±2.88% (27 runs sampled) | ||
Theta 0.8 x 4.74 ops/sec ±1.97% (16 runs sampled) | ||
Fastest is Theta 1.2 |
@@ -5,3 +5,3 @@ var Body = require('ngraph.physics.primitives').Body3d; | ||
var createQuadTree = require('../'), | ||
numberOfBodies = 1000; | ||
numberOfBodies = 10000; | ||
@@ -8,0 +8,0 @@ console.log('Bodies #' + numberOfBodies); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22815
500