Example usage for org.apache.commons.math3.analysis.interpolation TricubicInterpolator TricubicInterpolator

List of usage examples for org.apache.commons.math3.analysis.interpolation TricubicInterpolator TricubicInterpolator

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis.interpolation TricubicInterpolator TricubicInterpolator.

Prototype

TricubicInterpolator

Source Link

Usage

From source file:com.gordoni.opal.TriInterpolator.java

public TriInterpolator(MapPeriod mp, int what) {
    this.mp = mp;

    Scenario scenario = mp.scenario;/*w  w  w  . j  a  v a  2s.co  m*/
    Config config = scenario.config;

    xval = new double[mp.length[0]];
    for (int i = 0; i < xval.length; i++)
        xval[(xval.length - 1) - i] = scenario.scale[0].bucket_to_pf(mp.bottom[0] + i);
    yval = new double[mp.length[1]];
    for (int i = 0; i < yval.length; i++)
        yval[(yval.length - 1) - i] = scenario.scale[1].bucket_to_pf(mp.bottom[1] + i);
    zval = new double[mp.length[2]];
    for (int i = 0; i < zval.length; i++)
        zval[(zval.length - 1) - i] = scenario.scale[2].bucket_to_pf(mp.bottom[2] + i);

    fval = new double[mp.length[0]][mp.length[1]][mp.length[2]];
    MapPeriodIterator<MapElement> mpitr = mp.iterator();
    while (mpitr.hasNext()) {
        int[] bucket = mpitr.nextIndex().clone();
        MapElement me = mpitr.next();
        int xindex = (xval.length - 1) - (bucket[0] - mp.bottom[0]);
        int yindex = (yval.length - 1) - (bucket[1] - mp.bottom[1]);
        int zindex = (zval.length - 1) - (bucket[2] - mp.bottom[2]);
        fval[xindex][yindex][zindex] = getWhat(me, what);
    }

    TrivariateGridInterpolator interpolator;
    if (config.interpolation3.equals("spline"))
        interpolator = new TricubicInterpolator();
    else {
        assert (false);
        return;
    }

    this.f = interpolator.interpolate(xval, yval, zval, fval);
}