inverse-lerp
v1.0.1
Published
Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
Downloads
7
Maintainers
Readme
inverse-lerp
Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
Installation
npm install inverse-lerp
Usage
import inverseLerp from "inverse-lerp";
const range = [20, 40];
const [a, b] = range;
const value = 30;
const t = inverseLerp(a, b, value);
// => 0.5
API
inverseLerp
inverseLerp(a, b, v) ⇒ number ⏏
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 |
License
MIT. See license file.