Java Utililty Methods Lerp

List of utility methods to do Lerp

Description

The list of methods to do Lerp are organized into topic(s).

Method

intlerp(int a, int b, int mul, int div)
lerp
return a + (b - a) * mul / div;
doublelerpa(double a1, double a2, double t)
Linearly interpolates between two angles, taking the shortest path around the circle.
double ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2);
double d = Math.abs(a2 - a1), md = Math.abs(ma1 - ma2);
return (d <= md) ? lerp(a1, a2, t) : mirrorAngle(lerp(ma1, ma2, t));
intlerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2)
lerp And Premultiply Color With Alpha
int alpha = color1[0] + (int) (t * (color2[0] - color1[0]));
int red;
int green;
int blue;
if (alpha == 0) {
    red = 0;
    green = 0;
    blue = 0;
...
floatlerpAngle(float fromRadians, float toRadians, float progress)
Linearly interpolates between two angles in radians.
float delta = ((toRadians - fromRadians + PI2 + PI) % PI2) - PI;
return (fromRadians + delta * progress + PI2) % PI2;
floatLerpDegrees(float start, float end, float amount)
Lerp Degrees
float difference = Math.abs(end - start);
if (difference > 180) {
    if (end > start) {
        start += 360;
    } else {
        end += 360;
float value = (start + ((end - start) * amount));
float rangeZero = 360;
if (value >= 0 && value <= 360)
    return value;
return (value % rangeZero);
intlerpInt(int i1, int i2, double f)
lerp Int
return i1 + (int) ((i2 - i1) * f);
doublelerpQuad(double p0, double k0, double p1, double t)
lerp Quad
return p0 * (1 - t) * (1 - t) + 2 * k0 * (1 - t) * t + p1 * t * t;
floatlerpTowards(float from, float to, float factor)
lerp Towards
factor = Math.max(0, Math.min(1, factor));
return from * (1 - factor) + to * factor;