Skip to content

Instantly share code, notes, and snippets.

@woodnathan
Created June 20, 2014 06:08
Show Gist options
  • Save woodnathan/c069b3e599eba29ee03b to your computer and use it in GitHub Desktop.
Save woodnathan/c069b3e599eba29ee03b to your computer and use it in GitHub Desktop.
static inline CGFloat map(CGFloat input, CGFloat inMinimum, CGFloat inMaximum, CGFloat outMinimum, CGFloat outMaximum)
{
CGFloat returnValue;
CGFloat deltaIn = inMaximum - inMinimum;
CGFloat deltaOut = outMaximum - outMinimum;
returnValue = (input - inMinimum) / deltaIn;
returnValue = returnValue * deltaOut;
returnValue = returnValue + outMinimum;
return returnValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment