Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
npm install inverse-lerp
import inverseLerp from "inverse-lerp";
const range = [20, 40];
const [a, b] = range;
const value = 30;
const t = inverseLerp(a, b, value);
// => 0.5
Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
Kind: Exported function
Param | Type | Description |
---|---|---|
a | number |
Start |
b | number |
End |
v | number |
Value |
MIT. See license file.