# How can I Interpolating 3 variables?

This topic is 3657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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?

##### Share on other sites
Quote:
 Original post by haegarrOr 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]

##### Share on other sites
Quote:
 Original post by EmergentYou mean like,lerp(a, b, t) = (1 - t/T)*a + (t/T)*bwhere t is in the interval [0, T]?

This is 1D (unnormalized) lerp, exactly.

Quote:
 Original post by EmergentThe 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.

##### Share on other sites
Quote:
 Original post by haegarrThe 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.

##### Share on other sites
Quote:
 Original post by riruiloBut 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.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• ### Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• ### Who's Online (See full list)

There are no registered users currently online

×