Java Utililty Methods interpolate

List of utility methods to do interpolate

Description

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

Method

doubleinterpolate(double a, double b, double d)
interpolate
return a + (b - a) * d;
doubleinterpolate(double fromAngle, double toAngle, double ratio)
Interpolates angle according to rate, with correct 0->360 and 360->0 transitions
double delta = toAngle - fromAngle;
if (Math.abs(delta) > 180) {
    toAngle += delta > 0 ? -360 : 360;
return normalize(fromAngle + ratio * (toAngle - fromAngle));
doubleinterpolate(double oldP, double newP, float partialTicks)
interpolate
if (oldP == newP) {
    return oldP;
return oldP + ((newP - oldP) * partialTicks);
doubleinterpolate(double p0, double p1, double p2, double p3, double t)
Interpolation of Catmull-Rom Spline
double v0 = (p2 - p0) * 0.5;
double v1 = (p3 - p1) * 0.5;
double t2 = t * t;
double t3 = t * t2;
return (2.0 * p1 - 2.0 * p2 + v0 + v1) * t3 + (-3.0 * p1 + 3.0 * p2 - 2.0 * v0 - v1) * t2 + v0 * t + p1;
doubleinterpolate(double x, double x1, double y1, double x2, double y2)
Interpolate a value between two points.
double alpha = (x - x1) / (x2 - x1);
return y1 * (1 - alpha) + y2 * alpha;
doubleinterpolate(double x1, double x2, double inbetween)
interpolate
return x1 + (x2 - x1) * inbetween;
doubleinterpolate(double x1, double x2, float zeroToOne)
interpolate
if (zeroToOne == 1.0f)
    return x2;
return x1 + zeroToOne * (x2 - x1);
doubleinterpolate(final double min, final double max, final int currentClass, final int numOfClasses)
interpolate
return min + (currentClass * (max - min) / (numOfClasses - 1));
floatinterpolate(final float prev, final float curr, final float alpha)
interpolate
return (prev * (1 - alpha)) + (curr * alpha);
intinterpolate(final int n, final int lastN, final float interpolation)
interpolate
return Math.round(((n - lastN) * interpolation + lastN));