   [Help] linear interpolation
  I read the book "Introduction to 3D Game Programming with DirectX 9.0" and now i am stuck on a the chapter terrain there is a function is to calculate linear interpolation of heightfloat d3d::Lerp(float a, float b, float t){return a - (a*t) + (b*t);}but i have no idea why a - (a*t) + (b*t) and in the book he always give o.of to a parameter why?   
  a and b are 2 height values, in this case, namely the 2 that should be interpolated. t is the interpolation factor, to be chosen between 0 and 1 inclusively.Transforming a - a*t + b*t into the equivalent formula a*(1-t) + b*t, you have single occurances of a and b in the formula, seeing better what's happening: Each one of the heights is weighted by its interpolation weight (1-t) and t, resp., only determined from the interpolation factor. Notice that the sum of both weights is always 1. Now try some values of t on a piece of paper, and you'll understand.   ;Quote:Original post by haegarra and b are 2 height values, in this case, namely the 2 that should be interpolated. t is the interpolation factor, to be chosen between 0 and 1 inclusively.Transforming a - a*t + b*t into the equivalent formula a*(1-t) + b*t, you have single occurances of a and b in the formula, seeing better what's happening: Each one of the heights is weighted by its interpolation weight (1-t) and t, resp., only determined from the interpolation factor. Notice that the sum of both weights is always 1. Now try some values of t on a piece of paper, and you'll understand.ok thanks but why he give 0.0f to a parameter?;Quote:Original post by haegarra and b are 2 height values, in this case, namely the 2 that should be interpolated. t is the interpolation factor, to be chosen between 0 and 1 inclusively.Transforming a - a*t + b*t into the equivalent formula a*(1-t) + b*t, you have single occurances of a and b in the formula, seeing better what's happening: Each one of the heights is weighted by its interpolation weight (1-t) and t, resp., only determined from the interpolation factor. Notice that the sum of both weights is always 1. Now try some values of t on a piece of paper, and you'll understand.ok thanks but why he give 0.0f to a parameter?;  Without context (i.e., the calls he's making) it's impossible to answer that. My guess would be that these are just examples, and not good ones.   ;Quote:Original post by tomneo2004Quote:Original post by haegarra and b are 2 height values, in this case, namely the 2 that should be interpolated. t is the interpolation factor, to be chosen between 0 and 1 inclusively.Transforming a - a*t + b*t into the equivalent formula a*(1-t) + b*t, you have single occurances of a and b in the formula, seeing better what's happening: Each one of the heights is weighted by its interpolation weight (1-t) and t, resp., only determined from the interpolation factor. Notice that the sum of both weights is always 1. Now try some values of t on a piece of paper, and you'll understand.ok thanks but why he give 0.0f to a parameter?