2

I have a series of coordinates that represent data in a 2D scalar field: x[i], y[i], F[i]. However, x[i] and y[i] are not on a rectilinear grid, they are "randomly" placed. I want to interpolate f[i] so I can estimate its value on a rectilinear grid of locations in x, y.

This problem should be the same height interpolation of a terrain (see http://www.cs.uu.nl/geobook/interpolation.pdf). For example, if one has a height map of a terrain, it is not necessarily measured on a rectilinear grid. However, many maps would prefer the height on a rectilinear grid. Therefore the data must be interpolated to a rectilinear grid.

I use Matlab and it has a griddata command that performs interpolation to a rectilinear grid. The methodology uses Delaunay triangulation and some interpolation that is not described. I could guess at how this works, but it seems to me that this type of code should've already been written by someone else.

See: http://www.mathworks.com/help/matlab/ref/griddata.html?refresh=true for reference regarding how the griddata produces a rectilinear interpolation from "scatter" data.

I want to integrate the code into a C# application, so I'm looking for a library or source code to incorporate. ALGLIB will perform a cubic spline interpolation from uniformly spaced to uniformly spaced. I can't find anything that will work with non-uniformly spaced data.

Sascha
  • 1,210
  • 1
  • 17
  • 33
user3533030
  • 359
  • 3
  • 17

1 Answers1

0

You can make 2 triangles a quadrilateral. IMO a marching cube algorithm gives a rectilinear grid. You can try Paul Bourke conrec algorithm.

Micromega
  • 12,486
  • 7
  • 35
  • 72
  • I'm not sure I understand your recommendation. Marching cubes creates a mesh from uniformly distributed data. CONREC (http://paulbourke.net/papers/conrec/) also seems to require a rectilinear grid. Right? – user3533030 Jan 04 '16 at 15:46
  • No. Marching cube creates rectilinear grid Delaunay triangulation creates smaller, better grid. DT is also more difficult. – Micromega Jan 04 '16 at 18:00
  • Perhaps I don't understand. Here are two places I started when researching Marching Cubes: https://en.wikipedia.org/wiki/Marching_cubes and http://graphics.stanford.edu/~mdfisher/MarchingCubes.html . Each of these describes a method of creating polygonal meshes from a rectilinear "marching" through a known function / surface. I don't see how that relates to my problem. Can you point me towards some references or provide some additional details? – user3533030 Jan 04 '16 at 18:05
  • I have a set of data points that are not uniformly distributed. They sample a plane and the values of a scalar function on that plane. I wish to re-sample (interpolate) that scalar function to a rectilinear grid. – user3533030 Jan 04 '16 at 18:07
  • Rectilinear is the input. Check the marching cube thing. Paul Bourke also has DT algorithm. – Micromega Jan 04 '16 at 18:08
  • Take a look at this: http://www.mathworks.com/help/matlab/ref/griddata.html?refresh=true – user3533030 Jan 04 '16 at 18:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/99717/discussion-between-user3533030-and-phpdevpad). – user3533030 Jan 04 '16 at 18:15
  • Are you proposing the nearest neighbor value based upon Manhattan distance to the nearest triangle created by the Delaunay method? – user3533030 Jan 04 '16 at 18:37
  • No. I use linear interpolation. – Micromega Jan 04 '16 at 18:56
  • I get the impression that Matlab uses DL to create triangles and then linearly interpolates data with the plane formed by the triangles. I cannot find C# code that performs this interpolation. Seems like I need to write my own... right? – user3533030 Jan 04 '16 at 19:08
  • You can try my PHP implementation https://contourplot.codeplex.com/ and/or https://cntm.codeplex.com. I created it for NASA. – Micromega Jan 04 '16 at 19:13