diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-06 15:03:15 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-07 08:51:35 +0300 |
| commit | 764dbe75a254d5a40fdefbebfb529add1d9dfb90 (patch) | |
| tree | 7e935c702eed632584aff1875d647a6ee0929136 /scripts | |
| parent | 853fcff36c500f5317e58fbff3a1700044076343 (diff) | |
rhizicore: add debug print if NaN's introduced in translate
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/rhizicore.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index 29944756..34cfddc2 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -701,6 +701,14 @@ var debug_print = function(message) { } } +function check_for_nan(x) { + if (Number.isNaN(x)) { + console.log('nan problem'); + force.stop(); + } + return Number.isNaN(x); +} + var newnodes=1; function tick(e) { //console.log(e); @@ -708,6 +716,9 @@ function tick(e) { function transform(d) { if (graphstate === "GRAPH" || d.type === "deliverable") { + if (check_for_nan(d.x) || check_for_nan(d.y)) { + return; + } if (d.state === "temp") { return "translate(" + d.x + "," + d.y + ")"; } else { @@ -772,10 +783,12 @@ function tick(e) { if(d.type==="chainlink" || d.type==="bubble"){ d.x = window.innerWidth / 2; d.y = window.innerHeight / 2; - }else{ - d.x = window.innerWidth / 2 + (60+newnodes*20) * Math.cos(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); - d.y = window.innerHeight / 2 + (60+newnodes*20) * Math.sin(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); + } else { + d.x = window.innerWidth / 2 + (60+newnodes*20) * Math.cos(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); + d.y = window.innerHeight / 2 + (60+newnodes*20) * Math.sin(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); } + check_for_nan(d.x); + check_for_nan(d.y); } }); } |
