Skip to content

Instantly share code, notes, and snippets.

@DeveloperPaul123
Created August 12, 2019 00:33
Show Gist options
  • Save DeveloperPaul123/4ab1df90949019a7e62cbfe2e6c5ceb8 to your computer and use it in GitHub Desktop.
Save DeveloperPaul123/4ab1df90949019a7e62cbfe2e6c5ceb8 to your computer and use it in GitHub Desktop.
1D Interpolation
#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