Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2d interpolation

Status
Not open for further replies.

sunaj

Technical User
Feb 13, 2001
1,474
DK
Hi,

I'm looking for free 2d interpolation code. The only thing I found is from magic software ( but there is no documentation and no examples (and by c++ is not good enough to see through the code).

I want to use the code to grid data (not image manipulation), but that shouldn't make any difference...

Do you now of some code/dll ?
Or I would also settle for a good 2d scheme that I could implement myself.

Thx in advance
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Sunaj

There are some considerations here.

Is linear interpolation sufficient between points? Is the data known to be of a specific progression (Linear-Linear; Log-LInear; Log-Log; ... other)? Are ALL of the data sets the same 'progresion'? Is it for a specific data set? Can the data set be fitted to a function -and hte function used instead of the interpolation?

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Hi Michael,

Linear interpolation is not good enough. The datasets does not have a specific progression (as it is different data geographically randomly distributed). The data cannot be fitted to a function.
The most commonly used methods for this type of data is spline or kriging interpolation.

Do you know of any code/dll sources?
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I'm a former Maths undergrad... You could use a technique called Natural Cubic Spline, but I've forgotten more about that than I remember...

As I recall, it revolves around calculus, and works by splitting the range into a number of intervals as defined by your known points. The idea then is that if Function A(X) applies between point i and i -1, and Function B applies between point i and i+1, you solve your equations such that

A(i) = b(i), and
dA/dx = dB/dx when x = i.

Roughly, something like that...

The drawback with this techniques is that you end up with a number of different functions defining what happens in the individual ranges from one point to another, which will be messy to handle in code...

However, the functions are cubic polynomials I think, so it's not too bad...

If you want to use this technique, have a look for stuff on the web. You might want to search the "NAG" libraries for Fortran, as I'm sure you'll find one in there for NCS.

Failing that, I have a mate who's doing his phD in Maths at St. John's, Oxford, so he might be able to help you out if you get desperate.

mmilan
 
Sunja,

I only have the code for the cubic spline in FORTRAN, and that only in hard copy. It's been a WHILE. If you don't get any other help, I will see if I can translate the material to VB, but I would need some source data and at least a few 'test points' for the test data to make sure it matches, or at least some critreria to say the results are O.K.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Good idea...

If it's important, and you get really stuck, I'll hit the books myself for you...

Martin.

 
Just found a PDF file, 50K, which has the 2 page "just what you need to know" summary of Natural Cublic Splines.

They're even good enough to provide sample code in QuickBasic, which ought not to be a challenge to convert...

You'll find the file at:

vbpj/1993/aprmay93/SandE.pdf
 
Sunaj, just a clarification, by 2D interpolation

Are you looking for an interpolation algorythm for 2 dimensional data, with 1 dimension being interpolated? This is the normal situation for polynomial, rational, trigonometric, and all of the splining techniques.
I do have a set of cubic spline functions, one to calculate the 2nd derivatives, and the other the perform the actual interpolation, but I'll have to go dig it up off a CD - haven't used it in a few years.

On the other hand, are you looking for an algorytm that interpolates across 2 dimensions of 3D data? If this is the case, you'll need something like an interative polynomial interpolation, or a bicubic spline. I don't have either of these, but I do have pascal code on paper for bicubics, and if you need it, I can provide it and help convert it

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Hi everybody,

Thank you very much for all your replies.

CajunCenturion, you have hit the spot. The data is geographically distubuted.
E.i. of the form x,y,f(x,y) where x & y is randomly distributed and f(x,y) is a measurerd value.

If you have pascal code for bicubic spline, I would be very interested. I did some Pascal years ago and should be able to translate it, if it not too messy.

[sunshine] Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Sunaj,
I found the following site which contains many of the algorythms for surface fitting, with a mathematical explanation of them.


I can still type in the Pascal code, but this may prove more useful.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top