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

doubleinterpolateClamp(final double position, final double startPosition, final double endPosition, final double startValue, final double endValue)
Calculates a linearily interpolated value, given a start value and position, an end value and position, and the position to get the value at.
double p = position;
if (p < startPosition) {
    p = startPosition;
} else if (p > endPosition) {
    p = endPosition;
return interpolate(p, startPosition, endPosition, startValue, endValue);
intinterpolateColor(double x, double y, int c0, int c1, int c2, int c3)
Performs bilinear interpolation of 32-bit colors over a convex quadrilateral.
int a0 = (c0 >> 24) & 0xff;
int r0 = (c0 >> 16) & 0xff;
int g0 = (c0 >> 8) & 0xff;
int b0 = c0 & 0xff;
int a1 = (c1 >> 24) & 0xff;
int r1 = (c1 >> 16) & 0xff;
int g1 = (c1 >> 8) & 0xff;
int b1 = c1 & 0xff;
...
intinterpolateColor(int a, int b, float w)
interpolate Color
return Math.max(0, Math.min(255, Math.round(a + (b - a) * w)));
intinterpolateColor(int c1, int c2, int st, int sts)
interpolate Color
return combine(interpolate(getR(c1), getR(c2), st, sts), interpolate(getG(c1), getG(c2), st, sts),
        interpolate(getB(c1), getB(c2), st, sts));
intinterpolateColor(int rgba1, int rgba2, float percent)
interpolate Color
int r1 = rgba1 & 0xFF, g1 = rgba1 >> 8 & 0xFF, b1 = rgba1 >> 16 & 0xFF, a1 = rgba1 >> 24 & 0xFF;
int r2 = rgba2 & 0xFF, g2 = rgba2 >> 8 & 0xFF, b2 = rgba2 >> 16 & 0xFF, a2 = rgba2 >> 24 & 0xFF;
int r = (int) (r1 < r2 ? r1 + (r2 - r1) * percent : r2 + (r1 - r2) * percent);
int g = (int) (g1 < g2 ? g1 + (g2 - g1) * percent : g2 + (g1 - g2) * percent);
int b = (int) (b1 < b2 ? b1 + (b2 - b1) * percent : b2 + (b1 - b2) * percent);
int a = (int) (a1 < a2 ? a1 + (a2 - a1) * percent : a2 + (a1 - a2) * percent);
return r | g << 8 | b << 16 | a << 24;
intinterpolateColors(int a, int b, float lerp)
interpolate Colors
final int MASK1 = 0xff00ff;
final int MASK2 = 0x00ff00;
int f2 = (int) (256 * lerp);
int f1 = 256 - f2;
return (((((a & MASK1) * f1) + ((b & MASK1) * f2)) >> 8) & MASK1)
        | (((((a & MASK2) * f1) + ((b & MASK2) * f2)) >> 8) & MASK2);
intinterpolateColors(int c0, int c1, float w)
Performs linear interpolation between two colors.
if (w <= 0)
    return c0;
if (w >= 1)
    return c1;
int a = interpolateColor((c0 >> 24) & 0xFF, (c1 >> 24) & 0xFF, w);
int r = interpolateColor((c0 >> 16) & 0xFF, (c1 >> 16) & 0xFF, w);
int g = interpolateColor((c0 >> 8) & 0xFF, (c1 >> 8) & 0xFF, w);
int b = interpolateColor((c0) & 0xFF, (c1) & 0xFF, w);
...
intinterpolateCubic(int x0, int x1, int x2, int x3, double t)
interpolate Cubic
int a0 = x3 - x2 - x0 + x1;
int a1 = x0 - x1 - a0;
int a2 = x2 - x0;
return (int) Math.max(0, Math.min(255, (a0 * (t * t * t)) + (a1 * (t * t)) + (a2 * t) + (x1)));
intinterpolatedNoise(int x, int z, int reciprocal)
Gets interpolated noise for the specified coordinate pair, using the specified frequency reciprocal.
int xt = x % reciprocal;
int zt = z % reciprocal;
x /= reciprocal;
z /= reciprocal;
int c = smoothNoise(x, z);
int e = smoothNoise(x + 1, z);
int ce = interpolate(c, e, xt, reciprocal);
int n = smoothNoise(x, z + 1);
...
doubleinterpolatedSample(double xStart, double xVal, double xEnd, double yStart, double yEnd)
interpolated Sample
return (xVal - xStart) * (yEnd - yStart) / (xEnd - xStart) + yStart;