Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
double mapf(double val, double in_min, double in_max, double out_min, double out_max) {
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

This comment has been minimized.

Copy link

@Kerlenton Kerlenton commented Aug 20, 2019

hello, for what using this function?


This comment has been minimized.

Copy link
Owner Author

@nadavmatalon nadavmatalon commented Aug 20, 2019


I wrote this a long time ago but as best I remember this function maps a given double-type number from one range onto another range. So for example, if you give it the number 5, input range of 1-10, and output range of 1-20 it will return 10.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment