Skip to content

Instantly share code, notes, and snippets.

@indefinit
Created November 13, 2013 16:20
Show Gist options
  • Save indefinit/7451808 to your computer and use it in GitHub Desktop.
Save indefinit/7451808 to your computer and use it in GitHub Desktop.
Linear transformation (Math) - map a value from one range to another
//map a value from one range to another
function mapVal(value, start1, stop1, start2, stop2) {
return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment