FANDOM


Linear interpolation, in computer graphics often called "LERP" (Linear interpolation), is a very (if not THE simplest) method of interpolation.

For a set of discrete values linear interpolation can approximate other values inbetween, assuming a linear developement between these discrete values. An interpolated value, calculated with linear interpolation, is calculated only in respect to the two surrounding values, which makes it a quite inappropriate choice if the desired curve should be smooth. If a curvier interpolation is needed, Splines might be an option.

To calculate a value between two other values, using linear interpolation, a certain factor, often called "step", must be used. The value has to be between value 1 (v0) and value 2 (v1). If "step" is 0.0 the interpolated value is equal to v0 and if step is 1.0, it's equal to v1. So the formula is as follows:

$ v0 * (1.0 - step) + v1 * step $

or (computationally a more efficient way):

$ v0 + (v1 - v0) * step $

AlternativelyEdit

Given two points ($ (x_0,y_0), (x_1,y_1) $) on a graph. A value $ (x_i,y_i) $ can be calculated like this:

$ y_i = y_0 * (1.0 - \frac{x_i - x_0}{x_1-x_0}) + y_1 * \frac{x_i - x_0}{x_1-x_0} $

or this:

$ y_i = y_0 + (y_1 - y_0)\frac{x_i - x_0}{x_1-x_0} $

Where $ \frac{x_i - x_0}{x_1-x_0} $ is the step-value.