Skip to content
This repository was archived by the owner on May 7, 2023. It is now read-only.

Files

Latest commit

 

History

History
21 lines (17 loc) · 454 Bytes

num-to-range.md

File metadata and controls

21 lines (17 loc) · 454 Bytes
title type tags cover dateModified
Map number to range
snippet
math
round-leaves
2021-04-05 18:25:46 +0300

Maps a number from one range to another range.

  • Return num mapped between outMin-outMax from inMin-inMax.
def num_to_range(num, inMin, inMax, outMin, outMax):
  return outMin + (float(num - inMin) / float(inMax - inMin) * (outMax
                  - outMin))
num_to_range(5, 0, 10, 0, 100) # 50.0