Simplifies a curve by dropping points based on perpendicular distance
Values of epsilon approaching zero keep more of the original points.
Making epsilon larger will filter out more points, making the curve more lossy and jagged.
// Source set of points that define the curve constpts = [ {x:100,y:200}, {x:10, y:20}, ... ];
constsimplified = rdpShortestDistance(pts, 3); // Yields an array of points
Simplifies a curve by dropping points based on perpendicular distance
Values of
epsilon
approaching zero keep more of the original points. Makingepsilon
larger will filter out more points, making the curve more lossy and jagged.It is an implementation of the Ramer Douglas Peucker algorithm by Marius Karthaus. Try the online playground: https://karthaus.nl/rdp/