Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't blow up when nodes overlap and you try to prettify

  • Loading branch information...
commit 1569c8101ee30955e256d43bdb79291486af55c6 1 parent ac7d0bf
Daniel Thornton authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 web/js/board.js
View
16 web/js/board.js
@@ -539,6 +539,14 @@ var Node = ScreenObject.extend({
r = k / Math.pow(r, 3);
force = [(r * dist[0]), (r * dist[1])];
+ // in case nodes touch, and we divide by zero...
+ if (!((force[0] >= 0) || (force[0] <= 0))) {
+ force[0] = 0;
+ }
+ if (!((force[1] >= 0) || (force[1] <= 0))) {
+ force[1] = 0;
+ }
+
return force;
},
@@ -569,6 +577,14 @@ var Node = ScreenObject.extend({
r = (k * (ideal -r))/r;
force = [(r * dist[0]), (r * dist[1])];
+ // in case nodes touch, and we divide by zero...
+ if (!((force[0] >= 0) || (force[0] <= 0))) {
+ force[0] = 0;
+ }
+ if (!((force[1] >= 0) || (force[1] <= 0))) {
+ force[1] = 0;
+ }
+
return force;
},
Please sign in to comment.
Something went wrong with that request. Please try again.