From 91d10053df91be1bbfb4f3c1109a60c241aacfad Mon Sep 17 00:00:00 2001 From: dsc Date: Thu, 10 Mar 2011 21:37:28 -0800 Subject: [PATCH] Protects against NaN in some trajectories. --- pavement.py | 3 ++- src/ezl/math/circle.cjs | 7 ++++++- src/ezl/math/line.cjs | 5 ++++- www/scripts.html | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pavement.py b/pavement.py index 21ca152..e676934 100755 --- a/pavement.py +++ b/pavement.py @@ -183,7 +183,8 @@ def clean(): @task -@needs('compress') +# @needs('compress') +@needs('build') @cmdopts([ ('exclude=', 'x', 'Exclude listed files (separate with commas).') ]) diff --git a/src/ezl/math/circle.cjs b/src/ezl/math/circle.cjs index d5b3227..2704fbc 100644 --- a/src/ezl/math/circle.cjs +++ b/src/ezl/math/circle.cjs @@ -1,8 +1,10 @@ var Y = require('Y').Y , Vec = require('ezl/math/vec').Vec + , _X = 0, _Y = 1 , + Circle = exports['Circle'] = Y.subclass('Circle', { @@ -38,7 +40,10 @@ Y.subclass('Circle', { timeToMove : function timeToMove(dx,dy){ if (dx instanceof Array) { dy=dx[1]; dx=dx[0]; } - return Math.abs( Math.acos(dx/this.radius) + Math.asin(dy/this.radius) ) * 0.5; // see note at iparametric + var _dx = Math.acos(dx/this.radius) + , _dy = Math.asin(dy/this.radius) + ; + return Math.abs((isNaN(_dx) || isNaN(_dy)) ? (isNaN(_dx) ? _dy : _dx) : ((_dx + _dy) * 0.5)); // see note at iparametric }, pointAtX : function pointAtX(x){ return this.parametric(Math.acos((x - this.x)/this.radius)); }, diff --git a/src/ezl/math/line.cjs b/src/ezl/math/line.cjs index 00e0575..c21edcb 100644 --- a/src/ezl/math/line.cjs +++ b/src/ezl/math/line.cjs @@ -66,7 +66,10 @@ Vec.subclass('Line', { */ timeToMove : function timeToMove(dx,dy){ if (dx instanceof Array) { dy=dx[1]; dx=dx[0]; } - return (Math.abs(dx/this.pa) + Math.abs(dy/this.pb)) * 0.5; // see note at iparametric + var _dx = Math.abs(dx/this.pa) + , _dy = Math.abs(dy/this.pb) + ; + return (isNaN(_dx) || isNaN(_dy)) ? (isNaN(_dx) ? _dy : _dx) : ((_dx + _dy) * 0.5); // see note at iparametric }, parametric : function parametric(t){ diff --git a/www/scripts.html b/www/scripts.html index 2222c8b..d71deaf 100644 --- a/www/scripts.html +++ b/www/scripts.html @@ -1,5 +1,5 @@
- +
-- 1.7.0.4