Before finding the fastest way to solve this problem, I would suggest finding a way to solve this problem. In short, I would suggest:
1) Find the Delaunay triangulation for points (x, y). The Fortran code for this, for example, is in GEOMPACK .
2) For interpolation, given the Delaunay triangulation, find the triangle that contains the point where the interpolation is to be performed, and then interpolate the z value based on the location of the point relative to each of the vertices of the triangle.
(EDIT) I forgot the name of the method (if I ever knew), but thanks to @Floris, a good approach to interpolating in a triangle is called barycentric interpolation , which finds the interpolated value based on the ratio of the areas in the three smaller triangles into which you can split the big triangle by drawing lines from a point inside a large triangle to each of the corners of the triangle. The area of each small triangle can be found along the length of each side of the triangle according to the Heron formula .
If speed improvements were needed, I think that they could be obtained mainly by finding a quick way to find a triangle that contains an interpolation point, but I would like to profile some test runs before choosing which bits of code to optimize.
Simon source share