Java Lerp lerp(double a, double b, double amt)

Here you can find the source of lerp(double a, double b, double amt)

Description

lerp

License

Open Source License

Declaration

public static double lerp(double a, double b, double amt) 

Method Source Code

//package com.java2s;

public class Main {
    public static double lerp(double a, double b, double amt) {
        amt = clamp(amt, 1F, 0F);// ww  w . j  a  va  2 s  . com
        return a * amt + b * (1D - amt);
    }

    public static float lerp(float a, float b, float amt) {
        amt = clamp(amt, 1F, 0F);
        return a * amt + b * (1F - amt);
    }

    public static double clamp(double val, double max, double min) {
        return val > max ? max : val < min ? min : val;
    }

    public static float clamp(float val, float max, float min) {
        return val > max ? max : val < min ? min : val;
    }

    public static int clamp(int val, int max, int min) {
        return val > max ? max : val < min ? min : val;
    }

    public static long clamp(long val, long max, long min) {
        return val > max ? max : val < min ? min : val;
    }

    public static short clamp(short val, short max, short min) {
        return val > max ? max : val < min ? min : val;
    }

    public static byte clamp(byte val, byte max, byte min) {
        return val > max ? max : val < min ? min : val;
    }
}

Related

  1. lerp(double a, double b, double f)
  2. lerp(double a, double b, double lambda)
  3. lerp(double a, double l, double h)
  4. lerp(double amt, double start, double end)