The Ramer-Douglas-Peucker Polygon Simplification Algorithm
One of the important algorithms in vector graphics and robotics is the Ramer-Douglas-Peucker algorithm. It simplifies a polygon by reducing the number of points by some tolerance. It was invented independently by Urs Ramer in 1972 and by David Douglas & Thomas Peucker in 1973. In 1992 it was improved by John Hershberger & Jack Snoeyink at the cost of the algorithm only working with simple 2D planar polylines, and not in higher dimentions.
0. Start with a polygon.
1. Make a polyline between the two endpoints. This is the initial approximation to the simplified polygon.
2. Calculate the distance between the edge and the remaining vertices. If the vertex tested is further away that the user defined tolerance, then the vertex is added to the simplification.
3. Repeat step 2 until you have a complete approximation of the polygon like shown in step 4 in the picture.
The idea with the algorithm is that we can give it an input like the one to the left and get an output like the one to the right:
This gives us a lot of possibilities; it can reconstruct the original representation of a polygon and it can provide us with compression of the data. A large and complicated polygon can be simplified down to the bare essentials by reducing the details of the polygon.
I’ve added this algorithm to Farseer Physics Engine 3.0.