Skip to content

Instantly share code, notes, and snippets.

@benregn
Created December 29, 2012 08:51
Show Gist options
  • Select an option

  • Save benregn/4405525 to your computer and use it in GitHub Desktop.

Select an option

Save benregn/4405525 to your computer and use it in GitHub Desktop.
A function to scale a value from a certain number range to different number range
def scale_value(value_to_scale, original_min, original_max, target_min, target_max):
return (((target_max - target_min) * (value_to_scale - original_min))/(original_max - original_min)) + target_min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment