Apologies in advance if I get terminologies wrong (not sure if "multidimensional interpolation" is the right term), I'm not really that great at maths, but here goes:
Suppose we have two 2D points, point A(x1,y1) and point B(x2, y2).
If we associate both Point A and point B with a z value, then for any point P in the map, we can determine it's z value by interpolating between points A and B's z values.
So if P is right in between A and B, the z value will be the average of the two, if it's right on A it'll have A's z value etc.
(to calculate the z value, we just get the conjugate of the complex number (B - A), multiply that with (P - A) and get it's x value and then interpolate as usual.
But what about when there's 3 points, or 4 points? I gather 3 points can be done easily, I mean you can already picture the 3 points as forming a plane.
But how do I get the "z" value for 4 or more points? Because I'm using this for a game I'm developing, the 4 points would always be a polygon, and I need interpolated points that are inside an edge of the polygon (that is, right in between two neighboring points), to be in a straight line..
My current approach right now is just to split the 4 points into two triangles, but I'd like to have something easier/faster on the CPU. Is there a way to come up with the interpolation without having to calculate each sub-triangle of the polygon?
p.s I have no idea what to tag this question as