This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static float lerp(float x, float x1, float x2, float q00, float q01) { | |
return ((x2 - x) / (x2 - x1)) * q00 + ((x - x1) / (x2 - x1)) * q01; | |
} | |
public static float biLerp(float x, float y, float q11, float q12, float q21, float q22, float x1, float x2, float y1, float y2) { | |
float r1 = lerp(x, x1, x2, q11, q21); | |
float r2 = lerp(x, x1, x2, q12, q22); | |
return lerp(y, y1, y2, r1, r2); | |
} |