Delphi function RamerDouglasPeucker(const path: TPath64; epsilon: double): TPath64;

Delphi function RamerDouglasPeucker(const paths: TPaths64; epsilon: double): TPaths64;

C++ inline Path<T> RamerDouglasPeucker(const Path<T>& path, double epsilon);

C++ inline Paths<T> RamerDouglasPeucker(const Paths<T>& path, double epsilon);

C# public static Path64 RamerDouglasPeucker(Path64 path, double epsilon);

C# public static Paths64 RamerDouglasPeucker(Paths64 path, double epsilon);

This function is based on an algorithm of the same name, and is very useful in removing extraneous path vertices. Somewhat simplistically, vertices will be removed when they are less than epsilon distance from an imaginary lines passing through their adjacent vertices. Logically, larger epsilon values will remove vertices more aggressively.

This function is particularly useful following offsetting (ie inflating/shrinking paths). Offsetting often creates tiny segments that don't improve path quality. Further these tiny segments create angles that are strongly influenced by integer rounding. While these tiny segments are too small to be noticeable following a single offset procedure, they're likely to degrade the quality of subsequent offsets. And they'll also degrade performance. Because of this, I strongly recommend calling this function after every polygon offset.

C++ Code Sample:
  #include "../../Clipper2Lib/clipper.h"
  #include "../../Utils/clipper.svg.h"
  #include "../../Utils/clipper.svg.utils.h"
  using namespace Clipper2Lib;
  int main()
    SvgReader svg_reader;
    PathsD p = svg_reader.GetPaths(), solution;

    while (p.size())
      //copy each iteration of 'p' into solution until 'p' is no more
      solution.reserve(solution.size() + p.size());
      copy(p.begin(), p.end(), back_inserter(solution));
      p = InflatePaths(p, -2.5, JoinType::Round, EndType::Polygon);
      //RamerDouglasPeucker - speeds up and tidies up the result
      p = RamerDouglasPeucker(p, 0.025);

    SvgAddSolution(svg, solution, false);
    SvgSaveToFile(svg, "rabbit_offset.svg", 338, 540, 0);

See Also