Skip to content

Linear Interpolation (Lerp)

Linear Interpolation (Lerp)

function lerp(a, b, t):   // t in [0,1]
    return a + (b - a) * t

function lerpVector(a, b, t):
    return (lerp(a.x, b.x, t), lerp(a.y, b.y, t))

Lerp is just a weighted average: at t=0 you get a, at t=1 you get b, and values in between blend proportionally. It's linear because equal steps in t produce equal steps in the output.