Java Lerp lerp(double a, double l, double h)

Here you can find the source of lerp(double a, double l, double h)

Description

Interpolates a value within a range.

License

Open Source License

Declaration

public static double lerp(double a, double l, double h) 

Method Source Code

//package com.java2s;
/*//from  ww w  . ja va  2s  . c o  m
 * Copyright (c) 2011, Paul Hertz 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
 * 3.0 of the License, or (at your option) any later version.
 * http://www.gnu.org/licenses/lgpl.html 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. You should have
 * received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301, USA
 * 
 * @author      ##author##
 * @modified   ##date##
 * @version      ##version##
 * 
 */

public class Main {
    /** 
     * Interpolates a value within a range.
     * linear interpolation from l (when a=0) to h (when a=1)
     * (equal to (a * h) + (1 - a) * l) 
     */
    public static double lerp(double a, double l, double h) {
        return l + a * (h - l);
    }

    /** 
     * Interpolates a value within a range.
     * linear interpolation from l (when a=0) to h (when a=1)
     * (equal to (a * h) + (1 - a) * l) 
     */
    public static float lerp(float a, float l, float h) {
        return l + a * (h - l);
    }
}

Related

  1. lerp(double a, double b, double amt)
  2. lerp(double a, double b, double f)
  3. lerp(double a, double b, double lambda)
  4. lerp(double amt, double start, double end)
  5. lerp(double distance, double firstPoint, double secondPoint)
  6. lerp(double from, double to, double p)
  7. lerp(double from, double to, double progress)