https://github.com/dmnsgn/inverse-lerp
Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
https://github.com/dmnsgn/inverse-lerp
interpolation inv-lerp inverse-lerp lerp
Last synced: 3 months ago
JSON representation
Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
- Host: GitHub
- URL: https://github.com/dmnsgn/inverse-lerp
- Owner: dmnsgn
- License: mit
- Created: 2024-03-23T22:37:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-06T14:13:14.000Z (11 months ago)
- Last Synced: 2025-01-09T21:37:12.961Z (5 months ago)
- Topics: interpolation, inv-lerp, inverse-lerp, lerp
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# inverse-lerp
[](https://www.npmjs.com/package/inverse-lerp)
[](https://www.npmjs.com/package/inverse-lerp)
[](https://bundlephobia.com/package/inverse-lerp)
[](https://github.com/dmnsgn/inverse-lerp/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/inverse-lerp/blob/main/LICENSE.md)Get a value's interpolant within a linear range, effectively remapping a value v within [a, b] to [0, 1].
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)
## Installation
```bash
npm install inverse-lerp
```## Usage
```js
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](https://github.com/dmnsgn/inverse-lerp/blob/main/LICENSE.md).