public List<Coordinate> getInterpolated() {
        List<Coordinate> p = new ArrayList<Coordinate>();
        if (pts.size() >= 2) {
            double[] xs = new double[pts.size()];
            double[] ys = new double[pts.size()];
            for( int i = 0; i < xs.length; i++ ) {
                Coordinate coordinate = pts.get(i);
                xs[i] = coordinate.x;
                ys[i] = coordinate.y;
            }

            Cubic[] X = calcNaturalCubic(pts.size() - 1, xs);
            Cubic[] Y = calcNaturalCubic(pts.size() - 1, ys);

            /* very crude technique - just break each segment up into steps lines */
            p.add(new Coordinate(X[0].eval(0), Y[0].eval(0)));
            for( int i = 0; i < X.length; i++ ) {
                for( int j = 1; j <= STEPS; j++ ) {
                    double u = j / (double) STEPS;
                    p.add(new Coordinate(X[i].eval(u), Y[i].eval(u)));
                }
            }
        }
        return p;
    }
public List < Coordinate > getInterpolated ( ) { List < Coordinate > p = new ArrayList < Coordinate > ( ) ; if ( pts . size ( ) >= 2 ) { double [ ] xs = new double [ pts . size ( ) ] ; double [ ] ys = new double [ pts . size ( ) ] ; for ( int i = 0 ; i < xs . length ; i ++ ) { Coordinate coordinate = pts . get ( i ) ; xs [ i ] = coordinate . x ; ys [ i ] = coordinate . y ; } Cubic [ ] X = calcNaturalCubic ( pts . size ( ) - 1 , xs ) ; Cubic [ ] Y = calcNaturalCubic ( pts . size ( ) - 1 , ys ) ; p . add ( new Coordinate ( X [ 0 ] . eval ( 0 ) , Y [ 0 ] . eval ( 0 ) ) ) ; for ( int i = 0 ; i < X . length ; i ++ ) { for ( int j = 1 ; j <= STEPS ; j ++ ) { double u = j / ( double ) STEPS ; p . add ( new Coordinate ( X [ i ] . eval ( u ) , Y [ i ] . eval ( u ) ) ) ; } } } return p ; }
/* draw a cubic spline