Probably embarrassing simple question, how to perform linear interpolation on a 2D dataset (a table) given x and y inputs?

(And higher dimensions for that matter, but 2D is my current need)

In order answer, we need better description of your problem.

My idea:

A LinearSpline (no problem with this one) is given by x’s and y’s and interpolate functions return linearly interpolated values as a function of these given a one dimensional input value(t).

A BilinearSpline (don’t know if correct term) could be constructed by giving the x’s of one dimension, the x’s of the other dimension and all the y’s in the intersections between x’s.

Interpolate function would thus take two input values (the t’s in each dimension) and return a final Bilinearly interpolated result.

And of course this could possibly be extended to any dimension.

Let me use my own notation. Consider a set of tuplets (Xi, Yi, Zi) for i = 1,n which are considered to be observations of a function f(X,Y) = Z. We want to estimate Zj for point (Xj, Yj), and we want to do it in a linear fashion based on a subset of tuplets.

Three points define a plane. Four or more points will, in general, not lie in a plane. If we choose three points to use, we can define a linear extrapolation. It’s not easy to choose the three points, however.

Thanks,

My points are “quadratic” and not triangular.

I solved it by making linear splines for each of the rows in the table, finding the nearest 2 splines in Y direction, interpolating these 2 splines with given x value which are stored as R1 and R2.Then making a new linear spline on these R’s and correcsponding Y values (could be done more directly, but I am too lazy) and finally interpolating the last spline giving me correct result.

I made an extension method for this and it works ok, but perhaps something for the library?

Note that it doesn’t matter if the “original” splines were row or column based and then “turning it all around” => same result.