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
const pts = [ {x:100,y:200}, {x:10, y:20}, ... ];

const simplified = rdpShortestDistance(pts, 3); // Yields an array of points

It is an implementation of the Ramer Douglas Peucker algorithm by Marius Karthaus. Try the online playground: https://karthaus.nl/rdp/

  • Parameters

    • points: Point[]
    • epsilon: number = 0.1

    Returns Point[]