/* PolylineExample * * A simple example of the use of the PolyLineSimplification class * * Author: Michael Thomas Flanagan * Date: 6 December 2011 */ import flanagan.interpolation.*; import flanagan.math.*; import flanagan.io.*; public class PolylineExample{ public static void main(String[] arg){ // x-coordinate dat double[] linex = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; // y-coordinate data double[] liney = {0, 2, 3, 6, 7, 8, 15, -5, 4, 1, -2, -3, -3, -1, 2, 4, 6, 7, 9}; // Combine above data as an array of Point Point[] curve = Point.oneDarray(linex, liney); // Enter thwe required tolerance double tolerance = Db.readDouble("Enter the tolerance ",8.0); // Create an instanceof PolylineSimplification PolylineSimplification dp = new PolylineSimplification(curve); // Perform Douglas-Peucker simplification Point[] pline = dp.douglasPeucker(tolerance); // Plot the original and simplified curves dp.plot(); } }