NAME

lerp - linearly interpolates or extrapolates between two values

SYNOPSIS

res = first.lerp(last, dist)

DESCRIPTION

Linearly interpolates or extrapolates between first and last based on dist.

Typically dist is between 0.0 and 1.0. If dist is 0.0, the result is first. If dist is 1.0, the result is last. If dist is below zero, the result is before first. If dist is above one, the result is after last.

The formula used is:

    first*(1.0 - dist) + last*dist

The function is vectorized across arrays. If any argument is an array, the array shapes must conform.

RETURN VALUE

Returns the interpolated value(s).

ERRORS

ArgCheck: Thrown if the number of arguments is not 2.
TypeCheck: Thrown if any of the arguments are not numeric, or if dist is not a floating point number.
ShapeCheck: Thrown if the arguments have non-conformable shapes

EXAMPLE

    10->lerp(20, 0.5)
15.

    0->lerp(10, 1.5)
15.

    10->lerp(20, [0.0, 0.5, 1.0])
10. 15. 20.

    [1,2].lerp([3,4],2.) // extrapolate
5. 6.

SEE ALSO

clamp
abs