Skip to content
Subhajit Sahu edited this page Aug 8, 2022 · 2 revisions

Linearly interpolate a number between two numbers.

Similar: constrain, normalize, remap, lerp.


function lerp(x, y, t)
// x: start number
// y: stop number
// t: interpolant ∈ [0, 1]

const xmath = require('extra-math');


xmath.lerp(80, 320, 0.8);
// → 272

xmath.lerp(80, 320, 0.20);
// → 128

xmath.lerp(80, 320, 0.32);
// → 156.8


References

Clone this wiki locally