Give CRelAngle signed value support

This commit is contained in:
Jack Andersen 2017-09-16 17:04:23 -10:00
parent 7e02e40cb2
commit 9d40c78f6e
1 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "zeus/CVector3f.hpp"
#include "zeus/Math.hpp"
#include <cmath>
namespace zeus
{
@ -15,10 +16,11 @@ struct CRelAngle
static float MakeRelativeAngle(float angle)
{
float ret = angle - std::floor(angle / (2.f * M_PIF)) * (2.f * M_PIF);
float absAngle = std::fabs(angle);
float ret = absAngle - std::floor(absAngle / (2.f * M_PIF)) * (2.f * M_PIF);
if (ret < 0.f)
ret += 2.f * M_PIF;
return ret;
return std::copysign(ret, angle);
}
CRelAngle() = default;