Does anybody know the algorithm behind the “reduce” component?
It is
Douglas-Peucker
The Ramer–Douglas–Peucker algorithm, also known as the Douglas–Peucker algorithm and iterative end-point fit algorithm, is an algorithm that decimates a curve composed of line segments to a similar curve with fewer points. It was one of the earliest successful algorithms developed for cartographic generalization.
The purpose of the algorithm is, given a curve composed of line segments (which is also called a Polyline in some contexts), to find a similar curve with fewer points. The algorithm de...
see this thread and go to MyJetBrain
When dealing with terrain data, often it is in the form of polylines, and depending on what data source it is from and how it has been scaled, they can be very, very dense. There is a component in Grasshopper that reduces polyline point count within a given tolerance (using the Douglas-Peucker algorithm if I’m not mistaken); it has also been implemented as a method in RhinoCommon - Rhino.Geometry. Polyline.ReduceSegments(tolerance). I have implemented several scripts here that use this.
My wi…
implemented it in C# because I needed it in an other application and I just implemented (2h ago !) a very poor version of the other one
Visvalingam Whyatt
The Visvalingam–Whyatt algorithm, also known as the Visvalingam's algorithm, is an algorithm that decimates a curve composed of line segments to a similar curve with fewer points.
Given a polygonal chain (often called a Polyline), the algorithm attempts to find a similar chain composed of fewer points.
Points are assigned an importance based on local conditions, and points are removed from the least important to most important.
In Visvalingam's algorithm, the importance is related to the trian...
4 Likes
I’m really grateful for your response. It confirmed my suspicions that it is the Douglas Peucker Algorithm
Mohammadrezaaalaei:
Douglas Peucker
If you are that suspicious (and you can read code) see what exactly DP does (and PlanB (Reumann) as well).
Reduce_curve_DP_or_R_V1.gh (134.7 KB)
3 Likes