public MultivariateFunction interpolate(Points points, int numberOfSpheres) {
        int length = points.getXVal().length;
        double[][] fVals = new double[length*length][2];
        double[] values = new double[length*length];

        int c = 0;
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                fVals[c][0] = points.getXVal()[i];
                fVals[c][1] = points.getYVal()[j];
                values[c] = points.getFVal()[i][j];
                c++;
            }
        }


        MicrosphereInterpolator interpolator = new MicrosphereInterpolator(numberOfSpheres, 2);
        return interpolator.interpolate(fVals, values);
    }