Skip to content

Allow arbor to deal with a single node. #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/physics/physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@

applyBarnesHutRepulsion:function(){
if (!_bounds.topleft || !_bounds.bottomright) return
var nParticles = 0;
for (var particle in active.particles)
nParticles++;
if (nParticles < 2) return

var bottomright = new Point(_bounds.bottomright)
var topleft = new Point(_bounds.topleft)

Expand Down Expand Up @@ -248,7 +253,7 @@
numParticles++
});

if (numParticles==0) return
if (numParticles < 2) return

var correction = centroid.divide(-numParticles)
$.each(active.particles, function(id, point) {
Expand Down Expand Up @@ -314,7 +319,8 @@
});

_energy = {sum:sum, max:max, mean:sum/n, n:n}
_bounds = {topleft:topleft||new Point(-1,-1), bottomright:bottomright||new Point(1,1)}
if (n > 1)
_bounds = {topleft:topleft||new Point(-1,-1), bottomright:bottomright||new Point(1,1)}
},

systemEnergy:function(timestep){
Expand Down