diff --git a/samples/blackmiscdbus/testservice.h b/samples/blackmiscdbus/testservice.h index a153a6b74..a638361ad 100644 --- a/samples/blackmiscdbus/testservice.h +++ b/samples/blackmiscdbus/testservice.h @@ -20,7 +20,7 @@ #include "blackmisc/networkallclasses.h" #include "blackmisc/pqallquantities.h" #include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/mathallclasses.h" +#include "blackmisc/math/math.h" #include "blacksim/fscommon/aircraftcfgentrieslist.h" #include "servicetool.h" #include diff --git a/src/blackmisc/aviation/comsystem.cpp b/src/blackmisc/aviation/comsystem.cpp index f7d33a446..67831067b 100644 --- a/src/blackmisc/aviation/comsystem.cpp +++ b/src/blackmisc/aviation/comsystem.cpp @@ -63,8 +63,8 @@ namespace BlackMisc quint32 d = static_cast(f / channelSpacingKHz); frequency.switchUnit(CFrequencyUnit::MHz()); double f0 = frequency.valueRounded(CFrequencyUnit::MHz(), 3); - double f1 = CMath::round(d * (channelSpacingKHz / 1000.0), 3); - double f2 = CMath::round((d + 1) * (channelSpacingKHz / 1000.0), 3); + double f1 = CMathUtils::round(d * (channelSpacingKHz / 1000.0), 3); + double f2 = CMathUtils::round((d + 1) * (channelSpacingKHz / 1000.0), 3); bool down = qAbs(f1 - f0) < qAbs(f2 - f0); // which is the closest value frequency.setCurrentUnitValue(down ? f1 : f2); } diff --git a/src/blackmisc/aviation/modulator.h b/src/blackmisc/aviation/modulator.h index 0bd6dd079..93d230064 100644 --- a/src/blackmisc/aviation/modulator.h +++ b/src/blackmisc/aviation/modulator.h @@ -14,7 +14,7 @@ #include "blackmisc/propertyindex.h" #include "blackmisc/aviation/avionicsbase.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" #include "blackmisc/blackmiscfreefunctions.h" namespace BlackMisc @@ -126,14 +126,14 @@ namespace BlackMisc //! Set active frequency virtual void setFrequencyActiveMHz(double frequencyMHz) { - frequencyMHz = Math::CMath::round(frequencyMHz, 3); + frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3); this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()); } //! Set standby frequency virtual void setFrequencyStandbyMHz(double frequencyMHz) { - frequencyMHz = Math::CMath::round(frequencyMHz, 3); + frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3); this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()); } diff --git a/src/blackmisc/blackmisc.h b/src/blackmisc/blackmisc.h index 10be0f156..593b200b5 100644 --- a/src/blackmisc/blackmisc.h +++ b/src/blackmisc/blackmisc.h @@ -18,11 +18,6 @@ * \brief Base and utility classes available in all other projects. */ -/*! - * \namespace BlackMisc::Math - * \brief Math classes such as vectors, matrices, and utility methods. - */ - /*! * \namespace BlackMisc::GeoPosition * \brief Position handling as geo locations and coordinates systems. diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index ce01086ae..59495b8cb 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -25,11 +25,13 @@ TRANSLATIONS += translations/blackmisc_i18n_de.ts \ HEADERS += *.h \ $$PWD/aviation/*.h \ + $$PWD/math/*.h \ $$PWD/simulation/*.h \ SOURCES += *.cpp \ $$PWD/aviation/*.cpp \ + $$PWD/math/*.cpp \ $$PWD/simulation/*.cpp \ diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp index 08b88e646..889b98da2 100644 --- a/src/blackmisc/blackmiscfreefunctions.cpp +++ b/src/blackmisc/blackmiscfreefunctions.cpp @@ -10,7 +10,7 @@ #include "blackmiscfreefunctions.h" #include "blackmisc/aviation/aviation.h" #include "pqallquantities.h" -#include "mathallclasses.h" +#include "math/math.h" #include "geoallclasses.h" #include "networkallclasses.h" #include "audioallclasses.h" diff --git a/src/blackmisc/coordinategeodetic.cpp b/src/blackmisc/coordinategeodetic.cpp index b34df997a..12f282057 100644 --- a/src/blackmisc/coordinategeodetic.cpp +++ b/src/blackmisc/coordinategeodetic.cpp @@ -10,7 +10,7 @@ #include "blackmisc/coordinategeodetic.h" #include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/propertyindex.h" -#include "mathematics.h" +#include "blackmisc/math/mathutils.h" #include "variant.h" #include @@ -79,8 +79,8 @@ namespace BlackMisc double x = qCos(lat1rad) * qSin(lat2rad) - qSin(lat1rad) * qCos(lat2rad) * qCos(dLon); double bearing = qAtan2(y, x); - bearing = CMath::rad2deg(bearing); // now in deg - bearing = CMath::normalizeDegrees(bearing); // normalize + bearing = CMathUtils::rad2deg(bearing); // now in deg + bearing = CMathUtils::normalizeDegrees(bearing); // normalize return CAngle(bearing, CAngleUnit::deg()); } diff --git a/src/blackmisc/geodesicgrid.h b/src/blackmisc/geodesicgrid.h index 3da671b94..1d31d350f 100644 --- a/src/blackmisc/geodesicgrid.h +++ b/src/blackmisc/geodesicgrid.h @@ -8,7 +8,7 @@ //! \file -#include "mathematics.h" +#include "blackmisc/math/mathutils.h" #include "coordinategeodetic.h" #include "range.h" #include "iterator.h" @@ -128,12 +128,12 @@ namespace BlackMisc { using namespace std; using namespace BlackMisc::Math; - Q_ASSERT(lat >= -CMath::PIHALF() && lat <= CMath::PIHALF()); - Q_ASSERT(lon >= -CMath::PI() && lon <= CMath::PI()); - static const double ratio = Slices / CMath::PI(); + Q_ASSERT(lat >= -CMathUtils::PIHALF() && lat <= CMathUtils::PIHALF()); + Q_ASSERT(lon >= -CMathUtils::PI() && lon <= CMathUtils::PI()); + static const double ratio = Slices / CMathUtils::PI(); Key x = qFloor(acos(cos(lat) * cos(lon)) * ratio); Key y = qFloor(acos(cos(lat) * sin(lon)) * ratio); - Key z = qFloor( (lat + CMath::PIHALF()) * ratio); + Key z = qFloor( (lat + CMathUtils::PIHALF()) * ratio); return (x << Xshift) | (y << Yshift) | (z << Zshift); } diff --git a/src/blackmisc/math/math.h b/src/blackmisc/math/math.h new file mode 100644 index 000000000..29ac1bbcc --- /dev/null +++ b/src/blackmisc/math/math.h @@ -0,0 +1,22 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_MATH_MATH_H +#define BLACKMISC_MATH_MATH_H + +/*! + * \namespace BlackMisc::Math + * \brief Math classes such as vectors, matrices, and utility methods. + */ + +#include "blackmisc/math/mathutils.h" + +#endif // guard diff --git a/src/blackmisc/mathematics.cpp b/src/blackmisc/math/mathutils.cpp similarity index 54% rename from src/blackmisc/mathematics.cpp rename to src/blackmisc/math/mathutils.cpp index 34f07cc96..0794d2084 100644 --- a/src/blackmisc/mathematics.cpp +++ b/src/blackmisc/math/mathutils.cpp @@ -1,20 +1,22 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ -#include "blackmisc/mathematics.h" -#include // std::max +#include "blackmisc/math/mathutils.h" +#include #include namespace BlackMisc { namespace Math { - /* - * Hypotenuse - */ - double CMath::hypot(double x, double y) + + double CMathUtils::hypot(double x, double y) { x = qAbs(x); y = qAbs(y); @@ -24,20 +26,14 @@ namespace BlackMisc return max * sqrt(1 + r * r); } - /* - * Real part of cubic root - */ - double CMath::cubicRootReal(double x) + double CMathUtils::cubicRootReal(double x) { double result; result = std::pow(qAbs(x), (double)1.0 / 3.0); return x < 0 ? -result : result; } - /* - * Round utility method - */ - double CMath::round(double value, int digits) + double CMathUtils::round(double value, int digits) { // gosh, is there no Qt method for this??? It's year 2013 double fractpart, intpart; @@ -49,10 +45,7 @@ namespace BlackMisc return rv; } - /* - * Round by given epsilon value - */ - double CMath::roundEpsilon(double value, double epsilon) + double CMathUtils::roundEpsilon(double value, double epsilon) { double fractpart, intpart; fractpart = modf(value, &intpart); @@ -62,35 +55,23 @@ namespace BlackMisc return rv; } - /* - * Equal, considering equal - */ - bool CMath::epsilonEqual(double v1, double v2, double epsilon) + bool CMathUtils::epsilonEqual(double v1, double v2, double epsilon) { if (v1 == v2) return true; return qAbs(v1 - v2) <= epsilon; } - /* - * To radians - */ - double CMath::deg2rad(double degree) + double CMathUtils::deg2rad(double degree) { - return degree * CMath::PI() / 180.0; + return degree * CMathUtils::PI() / 180.0; } - /* - * To radians - */ - double CMath::rad2deg(double radians) + double CMathUtils::rad2deg(double radians) { - return radians * 180.0 / CMath::PI(); + return radians * 180.0 / CMathUtils::PI(); } - /* - * Normalize degrees - */ - double CMath::normalizeDegrees(double degrees) + double CMathUtils::normalizeDegrees(double degrees) { double result = std::fmod(degrees, 360.0); return (result >= 0.0) ? result : result + 360.0; diff --git a/src/blackmisc/mathematics.h b/src/blackmisc/math/mathutils.h similarity index 80% rename from src/blackmisc/mathematics.h rename to src/blackmisc/math/mathutils.h index 6352999d3..425722c5e 100644 --- a/src/blackmisc/mathematics.h +++ b/src/blackmisc/math/mathutils.h @@ -1,10 +1,17 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_MATH_MATHUTILS_H +#define BLACKMISC_MATH_MATHUTILS_H -#ifndef BLACKMISC_MATHEMATICS_H -#define BLACKMISC_MATHEMATICS_H #include #include @@ -14,10 +21,13 @@ namespace BlackMisc { //! Math utils - class CMath + class CMathUtils { public: + //! No objects, just static + CMathUtils() = delete; + //! Calculates the hypotenuse of x and y without overflow static double hypot(double x, double y); @@ -87,12 +97,9 @@ namespace BlackMisc //! Normalize: 0≤ degrees <360 static double normalizeDegrees(double degrees); - - private: - //! No objects, just static - CMath(); }; } // namespace } // namespace + #endif // guard diff --git a/src/blackmisc/mathallclasses.h b/src/blackmisc/mathallclasses.h deleted file mode 100644 index 0bdf4325f..000000000 --- a/src/blackmisc/mathallclasses.h +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BLACKMISC_MATHALLCLASSES_H -#define BLACKMISC_MATHALLCLASSES_H - -#include "blackmisc/mathmatrix1x3.h" -#include "blackmisc/mathmatrix3x3.h" -#include "blackmisc/mathmatrix3x1.h" -#include "blackmisc/mathvector3d.h" - -#endif // guard diff --git a/src/blackmisc/pqangle.cpp b/src/blackmisc/pqangle.cpp index 12da0c327..68ca6a63e 100644 --- a/src/blackmisc/pqangle.cpp +++ b/src/blackmisc/pqangle.cpp @@ -24,12 +24,12 @@ namespace BlackMisc double CAngle::piFactor() const { - return BlackMisc::Math::CMath::round(this->value(CAngleUnit::rad()) / BlackMisc::Math::CMath::PI() , 6); + return BlackMisc::Math::CMathUtils::round(this->value(CAngleUnit::rad()) / BlackMisc::Math::CMathUtils::PI() , 6); } const double &CAngle::PI() { - return BlackMisc::Math::CMath::PI(); + return BlackMisc::Math::CMathUtils::PI(); } } } diff --git a/src/blackmisc/pqangle.h b/src/blackmisc/pqangle.h index 7a8a3cbd0..348dd5a1e 100644 --- a/src/blackmisc/pqangle.h +++ b/src/blackmisc/pqangle.h @@ -13,7 +13,7 @@ #define BLACKMISC_PQANGLE_H #include "blackmisc/pqphysicalquantity.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" namespace BlackMisc { diff --git a/src/blackmisc/pqbase.cpp b/src/blackmisc/pqbase.cpp index 349d89507..fe052325d 100644 --- a/src/blackmisc/pqbase.cpp +++ b/src/blackmisc/pqbase.cpp @@ -10,7 +10,7 @@ //! \file #include "blackmisc/pqbase.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" using namespace BlackMisc::Math; @@ -60,7 +60,7 @@ namespace BlackMisc double CMeasurementUnit::roundValue(double value, int digits) const { if (digits < 0) digits = this->m_displayDigits; - return CMath::round(value, digits); + return CMathUtils::round(value, digits); } /* @@ -69,7 +69,7 @@ namespace BlackMisc QString CMeasurementUnit::makeRoundedQString(double value, int digits, bool /* i18n */) const { if (digits < 0) digits = this->m_displayDigits; - double v = CMath::round(value, digits); + double v = CMathUtils::round(value, digits); QString s = QLocale::system().toString(v, 'f', digits); return s; } diff --git a/src/blackmisc/pqbase.h b/src/blackmisc/pqbase.h index 3f148af2a..6d934dd51 100644 --- a/src/blackmisc/pqbase.h +++ b/src/blackmisc/pqbase.h @@ -13,7 +13,7 @@ #define BLACKMISC_PQBASE_H #include "blackmisc/valueobject.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" #include "blackmisc/blackmiscfreefunctions.h" #include #include @@ -119,17 +119,17 @@ namespace BlackMisc { virtual double toDefault(double factor) const override { - using BlackMisc::Math::CMath; - double part2 = CMath::fract(factor) * SubdivPolicy::fraction(); - factor = CMath::trunc(factor) + part2 / SubdivPolicy::subfactor(); + using BlackMisc::Math::CMathUtils; + double part2 = CMathUtils::fract(factor) * SubdivPolicy::fraction(); + factor = CMathUtils::trunc(factor) + part2 / SubdivPolicy::subfactor(); return factor * FactorPolicy::factor(); } virtual double fromDefault(double factor) const override { - using BlackMisc::Math::CMath; + using BlackMisc::Math::CMathUtils; factor /= FactorPolicy::factor(); - double part2 = CMath::fract(factor) * SubdivPolicy::subfactor(); - return CMath::trunc(factor) + part2 / SubdivPolicy::fraction(); + double part2 = CMathUtils::fract(factor) * SubdivPolicy::subfactor(); + return CMathUtils::trunc(factor) + part2 / SubdivPolicy::fraction(); } }; @@ -143,19 +143,19 @@ namespace BlackMisc { virtual double toDefault(double factor) const override { - using BlackMisc::Math::CMath; - double part2 = CMath::fract(factor) * SubdivPolicy::fraction(); - double part3 = CMath::fract(part2) * SubdivPolicy::fraction(); - factor = CMath::trunc(factor) + (CMath::trunc(part2) + part3 / SubdivPolicy::subfactor()) / SubdivPolicy::subfactor(); + using BlackMisc::Math::CMathUtils; + double part2 = CMathUtils::fract(factor) * SubdivPolicy::fraction(); + double part3 = CMathUtils::fract(part2) * SubdivPolicy::fraction(); + factor = CMathUtils::trunc(factor) + (CMathUtils::trunc(part2) + part3 / SubdivPolicy::subfactor()) / SubdivPolicy::subfactor(); return factor * FactorPolicy::factor(); } virtual double fromDefault(double factor) const override { - using BlackMisc::Math::CMath; + using BlackMisc::Math::CMathUtils; factor /= FactorPolicy::factor(); - double part2 = CMath::fract(factor) * SubdivPolicy::subfactor(); - double part3 = CMath::fract(part2) * SubdivPolicy::subfactor(); - return CMath::trunc(factor) + (CMath::trunc(part2) + part3 / SubdivPolicy::fraction()) / SubdivPolicy::fraction(); + double part2 = CMathUtils::fract(factor) * SubdivPolicy::subfactor(); + double part3 = CMathUtils::fract(part2) * SubdivPolicy::subfactor(); + return CMathUtils::trunc(factor) + (CMathUtils::trunc(part2) + part3 / SubdivPolicy::fraction()) / SubdivPolicy::fraction(); } }; diff --git a/src/blackmisc/pqphysicalquantity.h b/src/blackmisc/pqphysicalquantity.h index 5d469502f..162307c1a 100644 --- a/src/blackmisc/pqphysicalquantity.h +++ b/src/blackmisc/pqphysicalquantity.h @@ -15,7 +15,7 @@ #include "blackmisc/pqbase.h" #include "blackmisc/pqunits.h" #include "blackmisc/propertyindex.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" #include "blackmisc/pqstring.h" #include "blackmisc/blackmiscfreefunctions.h" #include diff --git a/src/blackmisc/pqunits.cpp b/src/blackmisc/pqunits.cpp index 8cf930360..c2f0d88ed 100644 --- a/src/blackmisc/pqunits.cpp +++ b/src/blackmisc/pqunits.cpp @@ -13,7 +13,7 @@ namespace BlackMisc { namespace PhysicalQuantities { - using BlackMisc::Math::CMath; + using BlackMisc::Math::CMathUtils; /* * Rounded to QString @@ -26,9 +26,9 @@ namespace BlackMisc { digits -= 4; Q_ASSERT(digits >= 0); - double de = CMath::trunc(value); - double mi = CMath::trunc((value - de) * 100.0); - double se = CMath::trunc((value - de - mi / 100.0) * 1000000) / 100.0; + double de = CMathUtils::trunc(value); + double mi = CMathUtils::trunc((value - de) * 100.0); + double se = CMathUtils::trunc((value - de - mi / 100.0) * 1000000) / 100.0; const char *fmt = value < 0 ? "-%L1 %L2 %L3" : "%L1 %L2 %L3"; s = i18n ? QCoreApplication::translate("CMeasurementUnit", fmt) : fmt; s = s.arg(fabs(de), 0, 'f', 0).arg(fabs(mi), 2, 'f', 0, '0').arg(fabs(se), 2, 'f', digits, '0'); @@ -37,8 +37,8 @@ namespace BlackMisc { digits -= 2; Q_ASSERT(digits >= 0); - double de = CMath::trunc(value); - double mi = CMath::trunc((value - de) * 100.0); + double de = CMathUtils::trunc(value); + double mi = CMathUtils::trunc((value - de) * 100.0); const char *fmt = value < 0 ? "-%L1 %L2" : "%L1 %L2"; s = i18n ? QCoreApplication::translate("CMeasurementUnit", fmt) : fmt; s = s.arg(fabs(de), 0, 'f', 0).arg(fabs(mi), 2, 'f', digits, '0'); @@ -61,9 +61,9 @@ namespace BlackMisc { digits -= 4; Q_ASSERT(digits >= 0); - double hr = CMath::trunc(value); - double mi = CMath::trunc((value - hr) * 100.0); - double se = CMath::trunc((value - hr - mi / 100.0) * 1000000) / 100.0; + double hr = CMathUtils::trunc(value); + double mi = CMathUtils::trunc((value - hr) * 100.0); + double se = CMathUtils::trunc((value - hr - mi / 100.0) * 1000000) / 100.0; const char *fmt = value < 0 ? "-%L1h%L2m%L3s" : "%L1h%L2m%L3s"; s = i18n ? QCoreApplication::translate("CMeasurementUnit", fmt) : fmt; s = s.arg(fabs(hr), 2, 'f', 0, '0').arg(fabs(mi), 2, 'f', 0, '0').arg(fabs(se), 2, 'f', digits, '0'); @@ -72,8 +72,8 @@ namespace BlackMisc { digits -= 2; Q_ASSERT(digits >= 0); - double hr = CMath::trunc(value); - double mi = CMath::trunc((value - hr) * 100.0); + double hr = CMathUtils::trunc(value); + double mi = CMathUtils::trunc((value - hr) * 100.0); const char *fmt = value < 0 ? "-%L1h%L2m" : "%L1h%L2m"; s = i18n ? QCoreApplication::translate("CMeasurementUnit", fmt) : fmt; s = s.arg(fabs(hr), 2, 'f', 0, '0').arg(fabs(mi), 2, 'f', digits, '0'); @@ -82,8 +82,8 @@ namespace BlackMisc { digits -= 2; Q_ASSERT(digits >= 0); - double mi = CMath::trunc(value); - double se = CMath::trunc((value - mi) * 100.0); + double mi = CMathUtils::trunc(value); + double se = CMathUtils::trunc((value - mi) * 100.0); const char *fmt = value < 0 ? "-%L2m%L3s" : "%L2m%L3s"; s = i18n ? QCoreApplication::translate("CMeasurementUnit", fmt) : fmt; s = s.arg(fabs(mi), 2, 'f', 0, '0').arg(fabs(se), 2, 'f', digits, '0'); diff --git a/src/plugins/simulator/fs9/blacksimplugin_freefunctions.cpp b/src/plugins/simulator/fs9/blacksimplugin_freefunctions.cpp index d0de02dd0..89e4fce4b 100644 --- a/src/plugins/simulator/fs9/blacksimplugin_freefunctions.cpp +++ b/src/plugins/simulator/fs9/blacksimplugin_freefunctions.cpp @@ -10,7 +10,7 @@ #include "blacksimplugin_freefunctions.h" #include "fs9_host.h" #include "fs9_client.h" -#include "blackmisc/mathematics.h" +#include "blackmisc/math/mathutils.h" #include "blackmisc/logmessage.h" using namespace BlackMisc::Aviation; diff --git a/src/xbus/service.cpp b/src/xbus/service.cpp index b61dd018e..622b0fdb1 100644 --- a/src/xbus/service.cpp +++ b/src/xbus/service.cpp @@ -88,7 +88,7 @@ namespace XBus if (icao[0] != 0) { using namespace BlackMisc::Math; - m_airports.insert(CMath::deg2rad(lat), CMath::deg2rad(lon), i); + m_airports.insert(CMathUtils::deg2rad(lat), CMathUtils::deg2rad(lon), i); } } } @@ -115,7 +115,7 @@ namespace XBus using namespace BlackMisc::Math; QStringList icaos, names; QDoubleList lats, lons, alts; - for (auto navref : m_airports.inAdjacentTiles(CMath::deg2rad(getLatitude()), CMath::deg2rad(getLongitude()))) + for (auto navref : m_airports.inAdjacentTiles(CMathUtils::deg2rad(getLatitude()), CMathUtils::deg2rad(getLongitude()))) { float lat, lon, alt; char icao[32], name[256]; diff --git a/tests/blackmisc/testphysicalquantities.cpp b/tests/blackmisc/testphysicalquantities.cpp index 5c813de04..1664cbc46 100644 --- a/tests/blackmisc/testphysicalquantities.cpp +++ b/tests/blackmisc/testphysicalquantities.cpp @@ -69,8 +69,8 @@ namespace BlackMiscTest { CSpeed s1(100, CSpeedUnit::km_h()); CSpeed s2(1000, CSpeedUnit::ft_min()); - QVERIFY2(CMath::epsilonEqual(s1.valueRounded(CSpeedUnit::NM_h(), 0), 54), qPrintable(QString("100km/h is not %1 NM/h").arg(s1.valueRounded(CSpeedUnit::NM_h(), 0)))); - QVERIFY2(CMath::epsilonEqual(s2.valueRounded(CSpeedUnit::m_s(), 1), 5.1), qPrintable(QString("1000ft/min is not %1 m/s").arg(s2.valueRounded(CSpeedUnit::m_s(), 1)))); + QVERIFY2(CMathUtils::epsilonEqual(s1.valueRounded(CSpeedUnit::NM_h(), 0), 54), qPrintable(QString("100km/h is not %1 NM/h").arg(s1.valueRounded(CSpeedUnit::NM_h(), 0)))); + QVERIFY2(CMathUtils::epsilonEqual(s2.valueRounded(CSpeedUnit::m_s(), 1), 5.1), qPrintable(QString("1000ft/min is not %1 m/s").arg(s2.valueRounded(CSpeedUnit::m_s(), 1)))); } /* @@ -97,10 +97,10 @@ namespace BlackMiscTest CAngle a4(35.436, CAngleUnit::sexagesimalDegMin()); // 35.72666 CAngle a5(-60.3015, CAngleUnit::sexagesimalDeg()); // negative angles = west longitude or south latitude a2.switchUnit(CAngleUnit::deg()); - QVERIFY2(CMath::epsilonEqual(a1.piFactor(), 1.00), qPrintable(QString("Pi should be 1PI, not %1").arg(a1.piFactor()))); - QVERIFY2(CMath::epsilonEqual(a3.valueRounded(CAngleUnit::deg()), 35.73), "Expecting 35.73"); - QVERIFY2(CMath::epsilonEqual(a4.valueRounded(CAngleUnit::deg()), 35.73), "Expecting 35.73"); - QVERIFY2(CMath::epsilonEqual(a5.valueRounded(CAngleUnit::deg(), 4), -60.5042), "Expecting -60.5042"); + QVERIFY2(CMathUtils::epsilonEqual(a1.piFactor(), 1.00), qPrintable(QString("Pi should be 1PI, not %1").arg(a1.piFactor()))); + QVERIFY2(CMathUtils::epsilonEqual(a3.valueRounded(CAngleUnit::deg()), 35.73), "Expecting 35.73"); + QVERIFY2(CMathUtils::epsilonEqual(a4.valueRounded(CAngleUnit::deg()), 35.73), "Expecting 35.73"); + QVERIFY2(CMathUtils::epsilonEqual(a5.valueRounded(CAngleUnit::deg(), 4), -60.5042), "Expecting -60.5042"); } /* @@ -113,7 +113,7 @@ namespace BlackMiscTest w2.switchUnit(CMassUnit::tonne()); QVERIFY2(w2.value() == 1, "1tonne shall be 1000kg"); w2.switchUnit(CMassUnit::lb()); - QVERIFY2(CMath::epsilonEqual(w2.valueRounded(2), 2204.62), "1tonne shall be 2204pounds"); + QVERIFY2(CMathUtils::epsilonEqual(w2.valueRounded(2), 2204.62), "1tonne shall be 2204pounds"); QVERIFY2(w1 == w2, "Masses shall be equal"); } @@ -141,10 +141,10 @@ namespace BlackMiscTest CTemperature t2(1, CTemperatureUnit::F()); // 1F CTemperature t3(220.15, CTemperatureUnit::F()); CTemperature t4(10, CTemperatureUnit::F()); - QVERIFY2(CMath::epsilonEqual(t1.valueRounded(CTemperatureUnit::K()), 273.15), qPrintable(QString("0C shall be 273.15K, not %1 K").arg(t1.valueRounded(CTemperatureUnit::K())))); - QVERIFY2(CMath::epsilonEqual(t2.valueRounded(CTemperatureUnit::C()), -17.22), qPrintable(QString("1F shall be -17.22C, not %1 C").arg(t2.valueRounded(CTemperatureUnit::C())))); - QVERIFY2(CMath::epsilonEqual(t3.valueRounded(CTemperatureUnit::C()), 104.53), qPrintable(QString("220.15F shall be 104.53C, not %1 C").arg(t3.valueRounded(CTemperatureUnit::C())))); - QVERIFY2(CMath::epsilonEqual(t4.valueRounded(CTemperatureUnit::K()), 260.93), qPrintable(QString("10F shall be 260.93K, not %1 K").arg(t4.valueRounded(CTemperatureUnit::K())))); + QVERIFY2(CMathUtils::epsilonEqual(t1.valueRounded(CTemperatureUnit::K()), 273.15), qPrintable(QString("0C shall be 273.15K, not %1 K").arg(t1.valueRounded(CTemperatureUnit::K())))); + QVERIFY2(CMathUtils::epsilonEqual(t2.valueRounded(CTemperatureUnit::C()), -17.22), qPrintable(QString("1F shall be -17.22C, not %1 C").arg(t2.valueRounded(CTemperatureUnit::C())))); + QVERIFY2(CMathUtils::epsilonEqual(t3.valueRounded(CTemperatureUnit::C()), 104.53), qPrintable(QString("220.15F shall be 104.53C, not %1 C").arg(t3.valueRounded(CTemperatureUnit::C())))); + QVERIFY2(CMathUtils::epsilonEqual(t4.valueRounded(CTemperatureUnit::K()), 260.93), qPrintable(QString("10F shall be 260.93K, not %1 K").arg(t4.valueRounded(CTemperatureUnit::K())))); } /* @@ -156,10 +156,10 @@ namespace BlackMiscTest CTime t2(1.5, CTimeUnit::h()); CTime t3(1.25, CTimeUnit::min()); CTime t4(1.0101, CTimeUnit::hms()); - QVERIFY2(CMath::epsilonEqual(t1.value(CTimeUnit::defaultUnit()), 3600), "1hour shall be 3600s"); - QVERIFY2(CMath::epsilonEqual(t2.value(CTimeUnit::hrmin()), 1.3), "1.5hour shall be 1h30m"); - QVERIFY2(CMath::epsilonEqual(t3.value(CTimeUnit::minsec()), 1.15), "1.25min shall be 1m15s"); - QVERIFY2(CMath::epsilonEqual(t4.value(CTimeUnit::s()), 3661), "1h01m01s shall be 3661s"); + QVERIFY2(CMathUtils::epsilonEqual(t1.value(CTimeUnit::defaultUnit()), 3600), "1hour shall be 3600s"); + QVERIFY2(CMathUtils::epsilonEqual(t2.value(CTimeUnit::hrmin()), 1.3), "1.5hour shall be 1h30m"); + QVERIFY2(CMathUtils::epsilonEqual(t3.value(CTimeUnit::minsec()), 1.15), "1.25min shall be 1m15s"); + QVERIFY2(CMathUtils::epsilonEqual(t4.value(CTimeUnit::s()), 3661), "1h01m01s shall be 3661s"); } /* @@ -174,7 +174,7 @@ namespace BlackMiscTest CAcceleration a2(a1); a1.switchUnit(CAccelerationUnit::ft_s2()); QVERIFY2(a1 == a2, "Accelerations should be similar"); - QVERIFY2(CMath::epsilonEqual(BlackMisc::Math::CMath::round(a2.value() * ftFactor, 6), + QVERIFY2(CMathUtils::epsilonEqual(BlackMisc::Math::CMathUtils::round(a2.value() * ftFactor, 6), a1.valueRounded(6)), "Numerical values should be equal"); }