Java Lerp lerp(float a, float b, float f)

Here you can find the source of lerp(float a, float b, float f)

Description

Linearly interpolates between two floats

License

LGPL

Parameter

Parameter Description
a The starting float
b The ending float
f The percentage between the two floats

Return

The float which if f% between a and b

Declaration

public static float lerp(float a, float b, float f) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**//ww w. j  a  v a  2  s .c o m
     * Linearly interpolates between two floats
     *
     * @param a The starting float
     * @param b The ending float
     * @param f The percentage between the two floats
     * @return The float which if f% between a and b
     */
    public static float lerp(float a, float b, float f) {
        return a + f * (b - a);
    }

    /**
     * Linearly interpolates between two doubles
     *
     * @param a The starting double
     * @param b The ending dluble
     * @param f The percentage between the two double
     * @return The double which if f% between a and b
     */
    public static double lerp(double a, double b, double f) {
        return a + f * (b - a);
    }
}

Related

  1. lerp(final double a, final double min, final double max)
  2. lerp(final double percent, final int startColor, final int endColor)
  3. lerp(final float a, final float b, final float f)
  4. lerp(final float percent, final float startValue, final float endValue)
  5. lerp(final float x, final float x1, final float x2, final float q00, final float q01)
  6. lerp(float a, float b, float interpolation)
  7. lerp(float a, float b, float t)
  8. lerp(float fromValue, float toValue, float progress)
  9. lerp(float origin, float target, int steps, int maxSteps)