refactor: Use existing CMathUtils function

This commit is contained in:
Lars Toenning
2023-12-30 22:28:11 +01:00
parent 3c6a8c72f5
commit 2c461095d9

View File

@@ -20,6 +20,7 @@
#include "blackmisc/pq/length.h" #include "blackmisc/pq/length.h"
#include "blackmisc/pq/speed.h" #include "blackmisc/pq/speed.h"
#include "blackmisc/pq/time.h" #include "blackmisc/pq/time.h"
#include "blackmisc/math/mathutils.h"
#include "blackmisc/propertyindexref.h" #include "blackmisc/propertyindexref.h"
#include "blackmisc/timestampbased.h" #include "blackmisc/timestampbased.h"
#include "blackmisc/valueobject.h" #include "blackmisc/valueobject.h"
@@ -529,25 +530,29 @@ namespace BlackMisc
//! Both on ground //! Both on ground
static bool isGfEqualOnGround(double oldGroundFactor, double newGroundFactor) static bool isGfEqualOnGround(double oldGroundFactor, double newGroundFactor)
{ {
return isDoubleEpsilonEqual(1.0, oldGroundFactor) && isDoubleEpsilonEqual(1.0, newGroundFactor); using namespace BlackMisc::Math;
return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) && CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
} }
//! Both not on ground //! Both not on ground
static bool isGfEqualAirborne(double oldGroundFactor, double newGroundFactor) static bool isGfEqualAirborne(double oldGroundFactor, double newGroundFactor)
{ {
return isDoubleEpsilonEqual(0.0, oldGroundFactor) && isDoubleEpsilonEqual(0.0, newGroundFactor); using namespace BlackMisc::Math;
return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) && CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
} }
//! Aircraft is starting //! Aircraft is starting
static bool isGfStarting(double oldGroundFactor, double newGroundFactor) static bool isGfStarting(double oldGroundFactor, double newGroundFactor)
{ {
return isDoubleEpsilonEqual(0.0, oldGroundFactor) && isDoubleEpsilonEqual(1.0, newGroundFactor); using namespace BlackMisc::Math;
return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) && CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
} }
//! Aircraft is landing //! Aircraft is landing
static bool isGfLanding(double oldGroundFactor, double newGroundFactor) static bool isGfLanding(double oldGroundFactor, double newGroundFactor)
{ {
return isDoubleEpsilonEqual(1.0, oldGroundFactor) && isDoubleEpsilonEqual(0.0, newGroundFactor); using namespace BlackMisc::Math;
return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) && CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
} }
//! @} //! @}
@@ -588,12 +593,6 @@ namespace BlackMisc
double m_onGroundFactor = -1; //!< interpolated ground flag, 1..on ground, 0..not on ground, -1 no info double m_onGroundFactor = -1; //!< interpolated ground flag, 1..on ground, 0..not on ground, -1 no info
QString m_onGroundGuessingDetails; //!< only for debugging, not transferred via DBus etc. QString m_onGroundGuessingDetails; //!< only for debugging, not transferred via DBus etc.
//! Equal double values?
static bool isDoubleEpsilonEqual(double d1, double d2)
{
return qAbs(d1 - d2) <= std::numeric_limits<double>::epsilon();
}
BLACK_METACLASS( BLACK_METACLASS(
CAircraftSituation, CAircraftSituation,
BLACK_METAMEMBER(correspondingCallsign), BLACK_METAMEMBER(correspondingCallsign),