mirror of https://github.com/AxioDL/zeus.git
Make CRelAngle use [0,2pi] range
This commit is contained in:
parent
4352f0d4a9
commit
e6265e3c81
|
@ -12,11 +12,12 @@ struct CRelAngle {
|
||||||
float angle = 0.f;
|
float angle = 0.f;
|
||||||
|
|
||||||
static float MakeRelativeAngle(float angle) {
|
static float MakeRelativeAngle(float angle) {
|
||||||
float absAngle = std::fabs(angle);
|
if (angle == 2.f * M_PIF)
|
||||||
if (absAngle == 2.f * M_PIF)
|
return 2.f * M_PIF;
|
||||||
return std::copysign(absAngle, angle);
|
float ret = angle - std::trunc(angle / (2.f * M_PIF)) * (2.f * M_PIF);
|
||||||
float ret = absAngle - std::floor(absAngle / (2.f * M_PIF)) * (2.f * M_PIF);
|
if (ret < 0.f)
|
||||||
return std::copysign(ret, angle);
|
ret += 2.f * M_PIF;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRelAngle() = default;
|
CRelAngle() = default;
|
||||||
|
|
Loading…
Reference in New Issue