Sign in to follow this  
MERKB7661

Can someone help explain interpolation?

Recommended Posts

MERKB7661    120
I have seen some references in coding books and forum posts to interpolation coding. What exactly is interpolation, and how does it apply to programming?

Share this post


Link to post
Share on other sites
Tachikoma    575
Imagine you want to plot a line, whose endpoints are of two different colours. As you draw the line, you vary one colour to the other colour. That's an example of interpolation.

Interpolation is a very useful technique for "filling in the blanks" between points of data.

More info here:
https://secure.wikimedia.org/wikipedia/en/wiki/Interpolation

Share this post


Link to post
Share on other sites
frob    44972
[quote name='MERKB' timestamp='1306993790' post='4818538']
I have seen some references in coding books and forum posts to interpolation coding. What exactly is interpolation, and how does it apply to programming?
[/quote]

It is a way of moving smoothly between two points.


Example:
Your model starts in a square, and wants to slide to another square. The slide should take 3 seconds. You are currently at 1.21 seconds, so you interpolate to find the current location.

In that case you divide how far along you are from the total time (1.21 / 3.0 = 0.40333) so you are about 40% of the way through, then you figure out the point that is 0.40333 of the way through the animation. You have just interpolated your location between two points.

Share this post


Link to post
Share on other sites
inavat    317
[quote name='MERKB' timestamp='1306993790' post='4818538']
I have seen some references in coding books and forum posts to interpolation coding. What exactly is interpolation, and how does it apply to programming?
[/quote]

More generally, [b]interpolation [/b]is guessing about an unknown data point by analyzing information around it.


For example,
* If you know that on Sunday you had a full tank of gas and on Friday you were almost empty, you can use interpolation to guess that on Tuesday you had about half a tank.
* Or, if a plane took off from California at 7AM and reached New York at 1PM, you can use interpolation to guess that 10AM you might have been over Kansas.

There's another term called [b]extrapolation[/b]. Extrapolation is guessing about an unknown data point by analyzing a trend leading up to that point. To use the same examples:
* If you know that on Sunday you had a full tank of gas and on Tuesday you had about half a tank, you can use extrapolation to guess that you'll be empty by Friday.
* Or, if a plane takes off from California at 7AM and makes it to Kansas by 10AM, you can use extrapolation to guess that you'll reach New York by 1PM.

Interpolation is used for lots of things in games. Animation is a big one. Animation is usually specified with keyframes. So an animation of a man raising his hand might involve 3 keyframes. The first has his hand by his side, the second keyframe has his hand a bit higher up, and the last one has his hand completely raised. Three frames would make for a rather jerky animation, so you might use interpolation to make it smooth. You can figure out the position of his hand at as fine a time-step as you want by analyzing the keyframes around that time. If you show the animation over 100 frames, the man's hand will move a tiny amount each frame, and the position of the hand in all but the initial three frames will be calculated by you using interpolation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this