Here you can find the source of interpolate2D(final float wi, final float wj, final float x00, final float x10, final float x01, final float x11)
Parameter | Description |
---|---|
wi | weight in i-direction, a weight of 0.0 corresponds to i, 1.0 to i+1 |
wj | weight in j-direction, a weight of 0.0 corresponds to j, 1.0 to j+1 |
x00 | first anchor point located at (i,j) |
x10 | second anchor point located at (i+1,j) |
x01 | third anchor point located at (i,j+1) |
x11 | forth anchor point located at (i+1,j+1) |
public static float interpolate2D(final float wi, final float wj, final float x00, final float x10, final float x01, final float x11)
//package com.java2s; /*//from w w w . j av a 2 s. c o m * Copyright (C) 2010 Brockmann Consult GmbH (info@brockmann-consult.de) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) * any later version. * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, see http://www.gnu.org/licenses/ */ public class Main { /** * Performs a fast linear interpolation in two dimensions i and j. * * @param wi weight in i-direction, a weight of 0.0 corresponds to i, 1.0 to i+1 * @param wj weight in j-direction, a weight of 0.0 corresponds to j, 1.0 to j+1 * @param x00 first anchor point located at (i,j) * @param x10 second anchor point located at (i+1,j) * @param x01 third anchor point located at (i,j+1) * @param x11 forth anchor point located at (i+1,j+1) * * @return the interpolated value */ public static float interpolate2D(final float wi, final float wj, final float x00, final float x10, final float x01, final float x11) { return x00 + wi * (x10 - x00) + wj * (x01 - x00) + wi * wj * (x11 + x00 - x01 - x10); } /** * Performs a fast linear interpolation in two dimensions i and j. * * @param wi weight in i-direction, a weight of 0.0 corresponds to i, 1.0 to i+1 * @param wj weight in j-direction, a weight of 0.0 corresponds to j, 1.0 to j+1 * @param x00 first anchor point located at (i,j) * @param x10 second anchor point located at (i+1,j) * @param x01 third anchor point located at (i,j+1) * @param x11 forth anchor point located at (i+1,j+1) * * @return the interpolated value */ public static double interpolate2D(final double wi, final double wj, final double x00, final double x10, final double x01, final double x11) { return x00 + wi * (x10 - x00) + wj * (x01 - x00) + wi * wj * (x11 + x00 - x01 - x10); } }