Created
August 12, 2019 00:33
-
-
Save DeveloperPaul123/4ab1df90949019a7e62cbfe2e6c5ceb8 to your computer and use it in GitHub Desktop.
1D Interpolation
This file contains 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
#include <iostream> | |
#include <cmath> | |
double interpolate(double input_min, double input_max, double output_min, double output_max, double input_value) | |
{ | |
return output_min + ((output_max - output_min)/(input_max - input_min)) * (input_value - input_min); | |
} | |
int main() | |
{ | |
std::cout << std::floor(interpolate(-180.0, 180.0, 0.0, 359.0, 152.63)) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment