Check for denominator == 0 with tolerance.

This commit is contained in:
Jürg Lehni 2011-06-05 21:59:42 +01:00
parent 0366752a6f
commit 10e1417dc2

View file

@ -196,7 +196,7 @@ var PathFitter = Base.extend({
// Compute f(u)/f'(u)
var V = Q_u.subtract(P),
df = Q1_u.dot(Q1_u) + V.dot(Q2_u);
if (df == 0)
if (Math.abs(df) < Numerical.TOLERANCE)
return u;
// u = u - f(u) / f'(u)
return u - V.dot(Q1_u) / df;