Computes a linear interpolation between two values. - Java java.lang

Java examples for java.lang:Math Calculation

Description

Computes a linear interpolation between two values.

Demo Code


//package com.java2s;

public class Main {
    /**//from www.j av  a  2s  .  com
     * Computes a linear interpolation between two values.
     * @param f the interpolation fraction (typically between 0 and 1)
     * @param min the minimum value (corresponds to f==0)
     * @param max the maximum value (corresponds to f==1)
     * @return the interpolated value
     */
    public static double linearInterp(final double f, final double min,
            final double max) {
        return min + f * (max - min);
    }
}

Related Tutorials