# Linear interpolation of cube corner vals inside cube

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

## Recommended Posts

This should be straightforward, but I have a feeling that there should be some mathematical law or something that I'm not using. I have a cube with each of the 8 corners assigned a different value. I have a point somewhere inside that cube. I need to find the linearly interpolated value at that point using the values at the 8 corners of the cube. The way I'm doing it now is to get each of the 8 corner values and use the distance to each over the total distance to all as the ratio of their contribution to the final value. I have a feeling, though, that at least the total distance to all the corners is a constant depending on cube size, but I have no idea what that is. Just ignore that previous paragraph if I'm waffling, my main problem remains, can anyone give me a general solution to this interpolation problem? Cheers,

##### Share on other sites
I don't know either, but I have a few suggestions:

- output the computed distance on the screen, so that you'll see what type of value it is, and maybe you'll start to suspect what kind of equation it is

- simplify the problem to 2d rectangle - draw a rectangle on a piece of paper, draw a point and connect it with two corners, and draw a line between two corners, and try to do sth with the triangle that you'll get

HTH

##### Share on other sites
Hi.

This is a common problem within volume rendering and isosurfacing: given a cube with 8 values at its vertices, what is the value at a point p within the cube. The usual approach is to use trilinear interpolation. There are a lot papers describing this. For example, see the beggining os section 2 of this paper.

##### Share on other sites
Quote:
 Original post by wolverineFor example, see the beggining os section 2 of this paper.

Awesome, exactly the info I needed, thanks. Looks like I was completely wrong in my previous implementation - which actually might just explain a few problems I've been having.

Thanks again.

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 13
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633692
• Total Posts
3013355
×