From ca18b207854e2eb364ccc10a6b6b264bc8e49041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 5 Jun 2011 21:29:19 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20Douglas=E2=80=93Peucker=20algorithm=20?= =?UTF-8?q?again=20since=20it=20produced=20ackward=20results.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/path/PathFitter.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/path/PathFitter.js b/src/path/PathFitter.js index 6aab8742..809e7bc5 100644 --- a/src/path/PathFitter.js +++ b/src/path/PathFitter.js @@ -31,7 +31,6 @@ var PathFitter = Base.extend({ prev = point; } } - this.points = this.reducePoints(this.points, 1); this.error = error; this.iterationError = error * error; }, @@ -47,28 +46,6 @@ var PathFitter = Base.extend({ return this.segments; }, - // Douglas–Peucker algorithm - reducePoints: function(points, tolerance) { - var line = new Line(points[0], points[points.length - 1], false); - var maxDistance = 0, - maxIndex = 0; - for (var i = 1; i < points.length - 1; i++) { - var distance = line.getDistance(points[i]); - if(distance > maxDistance) { - maxDistance = distance; - maxIndex = i; - } - } - if (maxDistance >= tolerance) { - var pts = this.reducePoints( - points.slice(0, maxIndex + 1), tolerance); - pts.pop(); - return pts.concat(this.reducePoints( - points.slice(maxIndex, points.length), tolerance)); - } - return [points[0], points[points.length - 1]]; - }, - // Fit a Bezier curve to a (sub)set of digitized points fitCubic: function(first, last, tHat1, tHat2) { // Use heuristic if region only has two points in it