Skip to content

Instantly share code, notes, and snippets.

@said-and-done
Last active October 12, 2021 14:32
Show Gist options
  • Save said-and-done/3a091a41a527c212b3f31e7c8c2196d4 to your computer and use it in GitHub Desktop.
Save said-and-done/3a091a41a527c212b3f31e7c8c2196d4 to your computer and use it in GitHub Desktop.
Linear map input domain to output range
function linearmap(inMin, inMax, outMin, outMax) {
return function (x) {
return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment