Advertisement
ncot_tech

Remap number range

May 21st, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. # re-maps a number that is within one range, to be within another range
  2. # example remap 0-255 to be 0-1: remap(23,0,255,0,1)
  3. function remap(val,valmin,valmax,newmin,newmax)
  4. return ((val - valmin) / (valmax - valmin)) * (newmax - newmin) + newmin
  5. end-function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement