UNPKG
@kaliber/math
Version:
latest (1.1.3)
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
Math utilities
kaliberjs/math
@kaliber/math
/
src
/
unlerp.js
9 lines
(7 loc)
•
233 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
import
{ clamp
as
_clamp }
from
'./clamp'
export
function
unlerp
(
{ start, end, input, clamp =
false
}
) {
const
result = (input - start) / (end - start)
return
clamp ?
_clamp
({
min
:
0
,
max
:
1
,
input
: result }) : result }