Java Lerp lerp(final float percent, final float startValue, final float endValue)

Here you can find the source of lerp(final float percent, final float startValue, final float endValue)

Description

lerp

License

Open Source License

Parameter

Parameter Description
percent a parameter
startValue a parameter
endValue a parameter

Declaration

public static float lerp(final float percent, final float startValue, final float endValue) 

Method Source Code

//package com.java2s;
/**//from www .  ja v  a  2s  . c  om
 * Copyright (c) 2008-2012 Ardor Labs, Inc.
 *
 * This file is part of Ardor3D.
 *
 * Ardor3D is free software: you can redistribute it and/or modify it 
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
 */

public class Main {
    /**
     * 
     * @param percent
     * @param startValue
     * @param endValue
     * @return
     */
    public static float lerp(final float percent, final float startValue, final float endValue) {
        if (startValue == endValue) {
            return startValue;
        }
        return (1 - percent) * startValue + percent * endValue;
    }

    /**
     * 
     * @param percent
     * @param startValue
     * @param endValue
     * @return
     */
    public static double lerp(final double percent, final double startValue, final double endValue) {
        if (startValue == endValue) {
            return startValue;
        }
        return (1 - percent) * startValue + percent * endValue;
    }
}

Related

  1. lerp(double x, double x1, double x2, double q00, double q01)
  2. lerp(double x, double x1, double x2, double q00, double q01)
  3. lerp(final double a, final double min, final double max)
  4. lerp(final double percent, final int startColor, final int endColor)
  5. lerp(final float a, final float b, final float f)
  6. lerp(final float x, final float x1, final float x2, final float q00, final float q01)
  7. lerp(float a, float b, float f)
  8. lerp(float a, float b, float interpolation)
  9. lerp(float a, float b, float t)