SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.geometry.polyline

Class RamerDouglasPeucker

• java.lang.Object
• com.numericalmethod.suanshu.geometry.polyline.RamerDouglasPeucker

• public class RamerDouglasPeucker
extends Object
The Ramer-Douglas-Peucker algorithm simplifies a PolygonalChain by removing vertices which do not affect the shape of the curve to a given tolerance.

The algorithm works by finding the point which is farthest from the line segment defined by the endpoints. If the distance is within a specified tolerance, all vertices are removed but the endpoints. Otherwise, the list of line segments is divided into two parts: from the first point to the farthest point, and from the farthest point to the last point, then the algorithm recursively calls itself with these two parts (and the farthest point is kept).

Wikipedia: Ramer-Douglas-Peucker algorithm
• Constructor Summary

Constructors
Constructor and Description
RamerDouglasPeucker(double threshold)
Create an algorithm instance with a given threshold for the maximum distance between the original chain and a point in the simplified chain.
• Method Summary

All Methods
Modifier and Type Method and Description
PolygonalChain simplify(PolygonalChain chain)
Simplify the given polygonal chain.
• Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• Constructor Detail

• RamerDouglasPeucker

public RamerDouglasPeucker(double threshold)
Create an algorithm instance with a given threshold for the maximum distance between the original chain and a point in the simplified chain.
Parameters:
threshold - the threshold (non-negative)
• Method Detail

• simplify

public PolygonalChain simplify(PolygonalChain chain)
Simplify the given polygonal chain.
Parameters:
chain - the original polygonal curve
Returns:
the simplified curve