Java Lerp lerp(float to, float from, float f)

Here you can find the source of lerp(float to, float from, float f)

Description

lerp

License

Open Source License

Declaration

public static float lerp(float to, float from, float f) 

Method Source Code

//package com.java2s;
/**/* w  w  w.j a  v  a  2s .com*/
 * Created by DrunkMafia on 31/10/2014.
 * See http://www.wtfpl.net/txt/copying for licence
 */

public class Main {
    public static float lerp(float to, float from, float f) {
        float ret = (to > from ? to - f : to + f);
        if (withinThreshold(from, ret, 1))
            return from;
        return ret;
    }

    public static float lerp(float to, float from, float f, float threshold) {
        float ret = (to > from ? to - f : to + f);
        if (withinThreshold(from, ret, threshold))
            return from;
        return ret;
    }

    public static boolean withinThreshold(float a, float b, float threshold) {
        return Math.abs(a - b) < threshold;
    }
}

Related

  1. lerp(float a, float b, float t)
  2. lerp(float fromValue, float toValue, float progress)
  3. lerp(float origin, float target, int steps, int maxSteps)
  4. lerp(float start, float stop, float amt)
  5. lerp(float target, float current, float factor)
  6. lerp(float va, float vb, float t)
  7. lerp(float value1, float value2, float amount)
  8. lerp(int a, int b, float value)
  9. lerp(int a, int b, int mul, int div)