diff --git a/fitCurves.py b/fitCurves.py index e19d08e..5e9391b 100644 --- a/fitCurves.py +++ b/fitCurves.py @@ -148,7 +148,7 @@ def computeMaxError(points, bez, parameters): maxDist = 0.0 splitPoint = len(points)/2 for i, (point, u) in enumerate(zip(points, parameters)): - dist = linalg.norm(bezier.q(bez, u)-point)**2 + dist = ((bezier.q(bez, u) - point) ** 2).sum(-1) if dist > maxDist: maxDist = dist splitPoint = i @@ -157,5 +157,7 @@ def computeMaxError(points, bez, parameters): def normalize(v): - return v / linalg.norm(v) - + magnitude = sqrt(v.dot(v)) + if magnitude < finfo(float).eps: + return v + return v / magnitude