Kebab file names
This commit is contained in:
20
snippets/map-num-range.md
Normal file
20
snippets/map-num-range.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
title: Map number to range
|
||||
tags: math
|
||||
cover: clutter
|
||||
firstSeen: 2019-02-23T12:38:16+02:00
|
||||
lastUpdated: 2020-10-21T21:54:53+03:00
|
||||
---
|
||||
|
||||
Maps a number from one range to another range.
|
||||
|
||||
- Return `num` mapped between `outMin`-`outMax` from `inMin`-`inMax`.
|
||||
|
||||
```js
|
||||
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
|
||||
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
|
||||
```
|
||||
|
||||
```js
|
||||
mapNumRange(5, 0, 10, 0, 100); // 50
|
||||
```
|
||||
Reference in New Issue
Block a user