version 5.8.0
very important performance fix for normalizeAngleDeg...() methods, now fixed-speed (no "while") MQTT client release
This commit is contained in:
@@ -308,10 +308,12 @@ inline PIVector<T> piAbs(const PIVector<T> & v) {
|
||||
//! \~russian Нормализует угол к диапазону `[0; 360]` градусов на месте.
|
||||
template<typename T>
|
||||
void normalizeAngleDeg360(T & a) {
|
||||
while (a < 0.)
|
||||
a += 360.;
|
||||
while (a > 360.)
|
||||
a -= 360.;
|
||||
if (std::isnan(a) || std::isinf(a)) {
|
||||
a = 0.;
|
||||
return;
|
||||
}
|
||||
a -= std::floor(a / 360.) * 360.;
|
||||
if (a < 0) a += 360;
|
||||
}
|
||||
|
||||
//! \~english Returns an angle normalized to the `[0; 360]` degree range.
|
||||
@@ -327,10 +329,13 @@ double normalizedAngleDeg360(T a) {
|
||||
//! \~russian Нормализует угол к диапазону `[-180; 180]` градусов на месте.
|
||||
template<typename T>
|
||||
void normalizeAngleDeg180(T & a) {
|
||||
while (a < -180.)
|
||||
a += 360.;
|
||||
while (a > 180.)
|
||||
a -= 360.;
|
||||
if (std::isnan(a) || std::isinf(a)) {
|
||||
a = 0.;
|
||||
return;
|
||||
}
|
||||
a -= std::floor(a / 360.) * 360.;
|
||||
if (a < -180) a += 360;
|
||||
if (a >= 180) a -= 360;
|
||||
}
|
||||
|
||||
//! \~english Returns an angle normalized to the `[-180; 180]` degree range.
|
||||
|
||||
Reference in New Issue
Block a user