Skip to content

Instantly share code, notes, and snippets.

@Toscan0
Last active February 8, 2022 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Toscan0/67332bb8803606634680eca39f5bd696 to your computer and use it in GitHub Desktop.
Save Toscan0/67332bb8803606634680eca39f5bd696 to your computer and use it in GitHub Desktop.
Converts a number from one range to another range
private float NumberConvert(float oldValue, float oldMinScale, float oldMaxScale, float newMinScale, float newMaxScal)
{
float newVal = (((oldValue - oldMinScale) * (newMaxScal - newMinScale)) / (oldMaxScale - oldMinScale)) + newMinScale;
return newVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment