Skip to content

Instantly share code, notes, and snippets.

@joepol
Forked from dbrockman/degrees-radians.h
Last active February 27, 2020 07:37
Show Gist options
  • Save joepol/0a5552744c2aefe23da0ce72692b7d17 to your computer and use it in GitHub Desktop.
Save joepol/0a5552744c2aefe23da0ce72692b7d17 to your computer and use it in GitHub Desktop.
Convert degrees <-> radians [C++]
#include<math.h>
const double DEG_TO_RAD = (M_PI / 180.0);
const double RAD_TO_DEG = (180.0 / M_PI);
inline double DegreesToRadians(double angleDegrees){
return angleDegrees * DEG_TO_RAD;
}
inline double RadiansToDegrees(double angleRadians){
return angleRadians * RAD_TO_DEG;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment