lerp
Computes the linear interpolation between two given values.
Wikipedia: Linear interpolation is often used to fill the gaps in a table. Suppose you have a table listing the population of some country in 1970, 1980, 1990 and 2000, and that you want to estimate the population in 1994. Linear interpolation gives you an easy way to do this. The basic operation of linear interpolation between two values is so commonly used in computer graphics that it is sometimes called a lerp in that field's jargon. The term can be used as a verb or noun for the operation. e.g. "Bresenham's algorithm lerps incrementally between the two endpoints of the line."
/*
** Usage:
** out = lerp(t,a,b);
**
** Arguments:
** t fraction (0-1), real
** a lower value, real
** b upper value, real
**
** Returns:
** (a) if (t) is zero, (b) if (t) is one,
** for other values of (t) returns linear interpolation of
** (a) to (b) controlled by (t)
**
** GMLscripts.com
*/
{
return (argument1+argument0*(argument2-argument1));
}
** Usage:
** out = lerp(t,a,b);
**
** Arguments:
** t fraction (0-1), real
** a lower value, real
** b upper value, real
**
** Returns:
** (a) if (t) is zero, (b) if (t) is one,
** for other values of (t) returns linear interpolation of
** (a) to (b) controlled by (t)
**
** GMLscripts.com
*/
{
return (argument1+argument0*(argument2-argument1));
}
[Please Login]
Projects: 9
Contributor: xot
comments powered by Disqus

Related: