code: public Point2D.Double minDistancePointSpline(Point2D.Double p, int nPointsPerSegment){
  			double minDistance = Double.MAX_VALUE;
  			Point2D.Double minDistancePoint = null;
  		    int numberOfSplines = spline.getN();
  		    double[] knots = spline.getKnots();
  		    for(int i = 0; i < numberOfSplines; i++){
  		    	double x = knots[i];
  		    	double stopx = knots[i+1];
  		    	double dx = (stopx-x)/nPointsPerSegment;
  		    	
  		    	for(int j = 0; j < nPointsPerSegment; j++){
  		    		Point2D.Double candidate = new Point2D.Double(x, spline.value(x));
  		    		double d = p.distance(candidate);
  		    		if(d<minDistance){
  		    			minDistance = d;
  		    			minDistancePoint = candidate;
  		    		}
  		    		x += dx;
  		    	}
  		    	
  		    }
  		    return minDistancePoint;
  	}
docs: Finds to a given point p the point on the spline with minimum distance.
  @param p Point where the nearest distance is searched for
  @param nPointsPerSegment Number of interpolation points between two support points
  @return Point spline which has the minimum distance to p