-
Notifications
You must be signed in to change notification settings - Fork 0
remap
Subhajit Sahu edited this page Aug 8, 2022
·
2 revisions
Re-map a number from one range to another.
function remap(x, r, R, t, T)
// x: a number
// r: lower bound of current range
// R: upper bound of current range
// t: lower bound of target range
// T: upper bound of target range
const xmath = require('extra-math');
xmath.remap(25, 0, 100, 0, 1366);
// → 341.5
xmath.remap(110, 0, 100, -20, -10);
// → -9