Ramer–Douglas–Peucker algorithm: Difference between revisions

Content deleted Content added
Tag: Reverted
m Reverted 1 edit by 2804:214:8118:38CE:4475:C47B:DE32:9F78 (talk) to last revision by PhKindermann
Line 10:
 
<!--different implementation: The algorithm uses an array of boolean flags, initially set to not-kept, one for each point.-->
The algorithm [[recursion|recursively]] divides the line. Initially it is given all the points between the first and last point. It automatically marks the first and last point to be kept. It then finds the point that is farthest from the line segment with the first and last points as end points; this point is obviously farthest on the curve from the approximating line segment between the end points. If the point is closer than {{mvar|qwdqwdqwdqwdεε}} to the line segment, then any points not currently marked to be kept can be discarded without the simplified curve being worse than {{mvar|ε}}.
 
If the point farthest from the line segment is greater than {{mvar|ε}} from the approximation then that point must be kept. The algorithm recursively calls itself with the first point and the farthest point and then with the farthest point and the last point, which includes the farthest point being marked as kept.