I'm trying to 'morph' between 4 values, which I have mapped on 4 corners of a square plane in my user interface (A, B, C, D, see image below).

By selecting a point (P) within the boundaries of this plane I want to determine the interpolated value of P.

I've tried naively interpolating the X and Y coordinates and using pythagoras to calculate the distances from each of the corners, but none of my calculations end up correct.

What would be the mathematically correct method for determining the value of P, based on the values of A, B, C and D?

4 values on the corners of a 2D plane


Consider the issue as being 3D with values (numerical attributes) $v$ beared by $z$-axis.

Up to a change of variables, the coordinates of points $A,B,C,D$ can be taken resp. to be $(0,0,v_{00}),(1,0,v_{10}),(1,1,v_{11}),(0,1,v_{01})$.

In this case, a good solution is to use the "simple" (with quotes) surface guaranteed to pass through these 4 points has the following equation:

$$z=f(x,y)=(1-x)(1-y)v_{00}+x(1-y)v_{10}+(1-x)yv_{01}+xyv _{11}\tag{1}$$

(for example, when $x=1$ and $y=0$, the only nonzero "surviving" term is value $v_{10}$ precisely associated with point $(1,0,v_{10})$).

This method is called "bilinear interpolation".

Remarks :

a) You will find a more detailed explanation in my recent answer (First method) to (https://math.stackexchange.com/q/3219000).

b) Expanding terms in (1), one gets terms in $xy$ considered as second degree terms. It is normal to use these second degree terms because using only first degree terms would lead to plane equations. But in general the 3D points above aren't coplanar.

c) (1) is the equation of a so-called Hyperboloic Paraboloid (https://en.wikipedia.org/wiki/Paraboloid#Hyperbolic_paraboloid).

  • 1
    $\begingroup$ Brilliant, and very clearly explained for a non-maths-person like me! Thanks! $\endgroup$ – Bram Bos May 18 at 10:21
  • $\begingroup$ Happy that you have found it instructive. For a little more, see the reference I have just given as "Remark a)". $\endgroup$ – Jean Marie May 18 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.