Java interpolate interpolate2D(final float wi, final float wj, final float x00, final float x10, final float x01, final float x11)

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)

Description

Performs a fast linear interpolation in two dimensions i and j.

License

Open Source License

Parameter

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)

Return

the interpolated value

Declaration

public static float interpolate2D(final float wi, final float wj, final float x00, final float x10,
        final float x01, final float x11) 

Method Source Code

//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);
    }
}

Related

  1. interpolate(int v1, int v2, float f)
  2. interpolate(Long t, Long t1, Double m1, Long t2, Double m2)
  3. interpolate(long x1, long x2, double y1, double y2, long x)
  4. interpolate(String input, String parameter, String value)
  5. interpolate(String value)
  6. interpolateAngle(double oldAngle, double newAngle, double scale)
  7. interpolateAO(float a, float b, float c, float d)
  8. interpolateBrightness(int a, int b, int c, int d)
  9. interpolateClamp(final double position, final double startPosition, final double endPosition, final double startValue, final double endValue)