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;
|
||||
|
||||
static float MakeRelativeAngle(float angle) {
|
||||
float absAngle = std::fabs(angle);
|
||||
if (absAngle == 2.f * M_PIF)
|
||||
return std::copysign(absAngle, angle);
|
||||
float ret = absAngle - std::floor(absAngle / (2.f * M_PIF)) * (2.f * M_PIF);
|
||||
return std::copysign(ret, angle);
|
||||
if (angle == 2.f * M_PIF)
|
||||
return 2.f * M_PIF;
|
||||
float ret = angle - std::trunc(angle / (2.f * M_PIF)) * (2.f * M_PIF);
|
||||
if (ret < 0.f)
|
||||
ret += 2.f * M_PIF;
|
||||
return ret;
|
||||
}
|
||||
|
||||
CRelAngle() = default;
|
||||
|
|
Loading…
Reference in New Issue