Summary: Is there a name for the technique I describe below?
In this question I described a situation where I have four non-axis-aligned 2D input points mapping to output vectors, and a desire to map an arbitrary input point to a new output vector.
(-19,-7) -> (-150,-100)
( 10,-8) -> ( 150,-100)
(-11, 4) -> (-150, 100)
( 9, 7) -> ( 150, 100)
(-4.2,1) -> ( ??, ??)
Based on one answer I came up with my own algorithm, illustrated above as the green and orange calculations. See the answer for details, but in short: find the X intercept on the top and bottom lines, lerp the output values to those "north"/"south" locations, and then lerp between those outputs based on where the input point is on the line.
Comments on my answer indicate that what I'm doing cannot be called "bilinear interpolation". I believe that this is because I'm calculating different percentages for the top and bottom edges, and the way that I am doing this may cause some input points within the quad to result in output values outside the min/max of the corner output points.
- For example an input of (-19,0) in my scheme results in a point that is -40% along the bottom edge, and thus results in an output value of ~(-236,43), far less than the minX of -150.
If it's not "bilinear interpolation", what is this algorithm? And, if you'll permit a secondary question, how would you use bilinear interpolation on a non-parallelogram of inputs as I have here? Is that even possible?
Pretty visual test of my algorithm can be found on my website.