Package dev.nm.geometry.polyline
Class RamerDouglasPeucker
- java.lang.Object
-
- dev.nm.geometry.polyline.RamerDouglasPeucker
-
public class RamerDouglasPeucker extends Object
The Ramer-Douglas-Peucker algorithm simplifies aPolygonalChain
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).
-
-
Constructor Summary
Constructors Constructor 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 Instance Methods Concrete Methods Modifier and Type Method Description PolygonalChain
simplify(PolygonalChain chain)
Simplify the given polygonal chain.
-
-
-
Method Detail
-
simplify
public PolygonalChain simplify(PolygonalChain chain)
Simplify the given polygonal chain.- Parameters:
chain
- the original polygonal curve- Returns:
- the simplified curve
-
-