How can I Interpolating 3 variables?

Started by
5 comments, last by Dave Eberly 15 years, 7 months ago
Hi! Just one question. I would like to know, or to aproximate the value of a variable which depends of 2 variables. I know how to do this using just one variable and a spline or something like that. But how to do that with 3 variables? Probably is similar but I would like to hear your suggestions. And Is it a spline the proper way? Thanks a lot. Ricardo.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
This problem is exactly what image interpolation is. Say you have a monochrome image. This is really just a function from the (x,y) coordinates in the image to a brightness value. So if you look up image interpolation, most of the algorithms you'll find will be directly applicable to your problem. This also gives a nice way to visualize your problem.

Anyway, there are lots of techniques, including various spline methods. But I'd probably just recommend looking at,
1 - Bilinear interpolation
2 - Bicubic interpolation

Of these, #1 is the easiest, but #2 is usually "nicer." Both are very commonly-used.
Or perhaps the OP means a linear interpolation f=lerp(a,b,t) between 2 values a and b using the blending factor t, as opposed to a spline function f=spline(t) in t?
Quote:Original post by haegarr
Or perhaps the OP means a linear interpolation f=lerp(a,b,t) between 2 values a and b using the blending factor t, as opposed to a spline function f=spline(t) in t?


You mean like,

lerp(a, b, t) = (1 - t/T)*a + (t/T)*b

where t is in the interval [0, T]? The direct 2-d analogue of this is bilinear interpolation, n'est-ce pas? I.e.,

lerp(a,b,c,d,s,t) = (1 - s/S)[(1 - t/T)a + (t/T)b] + (s/S)[(1 - t/T)c + (t/T)d]
Quote:Original post by Emergent
You mean like,
lerp(a, b, t) = (1 - t/T)*a + (t/T)*b
where t is in the interval [0, T]?

This is 1D (unnormalized) lerp, exactly.

Quote:Original post by Emergent
The direct 2-d analogue of this is bilinear interpolation, n'est-ce pas? I.e.,
lerp(a,b,c,d,s,t) = (1 - s/S)[(1 - t/T)a + (t/T)b] + (s/S)[(1 - t/T)c + (t/T)d]

The question is (as was asked in the now deleted post between ours above) what exactly the OP is asking for. Interpolating between 2 variables happens normally in 1D, since 2 values is the minimum for interpolation and resticts usage to 1D. Bilinear lerp works in 2D and interpolates 4 values thoroughly. The OP explicitely speaks of 3 values, what can also mean quadratic interpolation in 1D. Or s/he named the blend factor the "3rd variable" and hence actually meant lerp in 1D. Or ... whatever. Hence my indirect request for more information.
Quote:Original post by haegarr
The question is (as was asked in the now deleted post between ours above) what exactly the OP is asking for. Interpolating between 2 variables happens normally in 1D, since 2 values is the minimum for interpolation and resticts usage to 1D. Bilinear lerp works in 2D and interpolates 4 values thoroughly. The OP explicitely speaks of 3 values, what can also mean quadratic interpolation in 1D. Or s/he named the blend factor the "3rd variable" and hence actually meant lerp in 1D. Or ... whatever. Hence my indirect request for more information.


Oh! I see.

So, what you are calling variables, I would normally call "values" to avoid confusion, since colloquially the line between "variable" and "function" is somewhat blurry (e.g., when we speak of "independent and dependent variables," the dependent "variable" is a function of the independent variable.)

(This is an intellectual "messiness" which I think is responsible for much confusion in elementary schools everywhere.)

Also, I noticed as well that there definitely is some inconsistency in the OP's post. He speaks of two variables, and then of three. I assumed that this meant that there were two independent variables, and one dependent variable. So really, to be clear, I was assuming that he wants to interpolate between samples of a scalar-valued function of two arguments.
Quote:Original post by riruilo
But how to do that with 3 variables? Probably is similar but I would like to hear your suggestions. And Is it a spline the proper way?


An example of B-spline volume interpolation is Mathematics, scroll to the end of the page and look at Wm4BSplineVolume.* files.

This topic is closed to new replies.

Advertisement