Java interpolate interpolate(int i, int n, float u1, float u2, float du)

Here you can find the source of interpolate(int i, int n, float u1, float u2, float du)

Description

interpolate

License

Open Source License

Declaration

public static float interpolate(int i, int n, float u1, float u2, float du) 

Method Source Code

//package com.java2s;
/*//  w ww.ja  v  a 2s  . co m
 * @(#)gl_util.java 0.3 06/11/20
 *
 * jGL 3-D graphics library for Java
 * Copyright (c) 1999-2006 Robin Bing-Yu Chen (robin@ntu.edu.tw)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version. the GNU Lesser
 * General Public License should be included with this distribution
 * in the file LICENSE.
 *
 * This library 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
 * Lesser General Public License for more details.
 */

public class Main {
    public static float interpolate(int i, int n, float u1, float u2, float du) {
        if (i == 0) {
            return u1;
        }
        if (i == n) {
            return u2;
        }
        return (u1 + i * du); // where du = (u2 - u1) / n
    }

    public static float interpolate(int i, int n, float u1, float u2) {
        float du = (u2 - u1) / n;
        return interpolate(i, n, u1, u2, du);
    }
}

Related

  1. interpolate(float firstColor, float secondColor, float stage, float maxStages)
  2. interpolate(float s, float e, float t)
  3. interpolate(float t, float a, float b)
  4. interpolate(float var1, float var2, float var3)
  5. interpolate(int a, int b, int theta, int reciprocal)
  6. interpolate(int start, int end, int n, int i)
  7. interpolate(int v1, int v2, float f)
  8. interpolate(int v1, int v2, float f)
  9. interpolate(Long t, Long t1, Double m1, Long t2, Double m2)