Last active
February 1, 2018 14:03
-
-
Save GMadorell/7551073 to your computer and use it in GitHub Desktop.
Scale an interval to another interval. Translate intervals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static float scaleInterval( | |
| float value, | |
| float minActualInterval, float maxActualInterval, | |
| float minDesiredInterval, float maxDesiredInterval) { | |
| return ((value - minActualInterval) / (maxActualInterval - minActualInterval)) | |
| * (maxDesiredInterval - minDesiredInterval) + minDesiredInterval; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def scale_interval(value, min_actual, max_actual, min_desired, max_desired): | |
| return ((value - min_actual) / (max_actual - min_actual)) \ | |
| * (max_desired - min_desired) + min_desired |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment