While we’re on the topic of interpolation, he’s how I calculate height on a uniform grid, by splitting a quad into two triangles:
public static final float interpolate2d(float x, float z, float nw, float ne, float se, float sw)
{
// n -= n % dim -> n = 0..dim (local offset)
x = x - (int) x;
z = z - (int) z;
// Which triangle of quad (left | right)
if (x > z)
sw = nw + se - ne;
else
ne = se + nw - sw;
// calculate interpolation of selected triangle
float n = lerp(x, nw, ne);
float s = lerp(x, sw, se);
return lerp(z, n, s);
}