Skip to content

Instantly share code, notes, and snippets.

@verma
Created April 4, 2012 19:36
Show Gist options
  • Save verma/2304994 to your computer and use it in GitHub Desktop.
Save verma/2304994 to your computer and use it in GitHub Desktop.
Normalize an Angle
static inline real_t NormalizeAngle(real_t rAngle) {
real_t a = std::fmod(rAngle, 2 * pd::math::PI);
if (IsGreaterOrEqual(a, pd::math::PI))
a = -2 * pd::math::PI + a;
else if (IsLessOrEqual(a, -pd::math::PI))
a = 2 * pd::math::PI + a;
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment