mirror of https://github.com/AxioDL/zeus.git
Give CRelAngle signed value support
This commit is contained in:
parent
7e02e40cb2
commit
9d40c78f6e
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "zeus/CVector3f.hpp"
|
#include "zeus/CVector3f.hpp"
|
||||||
#include "zeus/Math.hpp"
|
#include "zeus/Math.hpp"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace zeus
|
namespace zeus
|
||||||
{
|
{
|
||||||
|
@ -15,10 +16,11 @@ struct CRelAngle
|
||||||
|
|
||||||
static float MakeRelativeAngle(float angle)
|
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)
|
if (ret < 0.f)
|
||||||
ret += 2.f * M_PIF;
|
ret += 2.f * M_PIF;
|
||||||
return ret;
|
return std::copysign(ret, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRelAngle() = default;
|
CRelAngle() = default;
|
||||||
|
|
Loading…
Reference in New Issue