mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Rename CInterpolatorPbh to CInterpolatorLinearPbh
This commit is contained in:
@@ -567,7 +567,7 @@ add_library(misc SHARED
|
||||
simulation/xplane/xswiftbusconfigwriter.h
|
||||
simulation/matchingutils.h
|
||||
simulation/registermetadatasimulation.h
|
||||
simulation/interpolatorpbh.h
|
||||
simulation/interpolatorlinearpbh.h
|
||||
simulation/fsx/simconnectutilities.h
|
||||
simulation/fsx/simconnectutilities.cpp
|
||||
simulation/fsx/fsx.h
|
||||
@@ -602,7 +602,7 @@ add_library(misc SHARED
|
||||
simulation/interpolatorfunctions.h
|
||||
simulation/ownaircraftprovider.h
|
||||
simulation/distributorlistpreferences.cpp
|
||||
simulation/interpolatorpbh.cpp
|
||||
simulation/interpolatorlinearpbh.cpp
|
||||
simulation/reverselookup.h
|
||||
simulation/autopublishdata.cpp
|
||||
simulation/simulationenvironmentprovider.h
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLANT_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLANT_H
|
||||
|
||||
#include "blackmisc/simulation/interpolatorpbh.h"
|
||||
#include "blackmisc/simulation/interpolatorlinearpbh.h"
|
||||
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackMisc::Simulation
|
||||
m_startSituation(startSituation), m_pbh(0, startSituation, startSituation)
|
||||
{}
|
||||
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CInterpolatorPbh &pbh) : IInterpolant(1),
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CInterpolatorLinearPbh &pbh) : IInterpolant(1),
|
||||
m_startSituation(startSituation), m_pbh(pbh)
|
||||
{}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BlackMisc::Simulation
|
||||
{
|
||||
BLACK_VERIFY_X(isValidTimeFraction(m_simulationTimeFraction), Q_FUNC_INFO, "Time fraction needs to be within [0;1]");
|
||||
}
|
||||
m_pbh = CInterpolatorPbh(m_simulationTimeFraction, startSituation, endSituation);
|
||||
m_pbh = CInterpolatorLinearPbh(m_simulationTimeFraction, startSituation, endSituation);
|
||||
}
|
||||
|
||||
void CInterpolatorLinear::anchor()
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace BlackMisc
|
||||
//! Constructor
|
||||
CInterpolant() = default;
|
||||
CInterpolant(const Aviation::CAircraftSituation &startSituation);
|
||||
CInterpolant(const Aviation::CAircraftSituation &startSituation, const CInterpolatorPbh &pbh);
|
||||
CInterpolant(const Aviation::CAircraftSituation &startSituation, const CInterpolatorLinearPbh &pbh);
|
||||
CInterpolant(const Aviation::CAircraftSituation &startSituation, const Aviation::CAircraftSituation &endSituation, double timeFraction, qint64 interpolatedTime);
|
||||
//! @}
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace BlackMisc
|
||||
//! End situation
|
||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
||||
|
||||
CInterpolatorPbh pbh() const { return m_pbh; }
|
||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
||||
|
||||
private:
|
||||
Aviation::CAircraftSituation m_startSituation;
|
||||
Aviation::CAircraftSituation m_endSituation;
|
||||
double m_simulationTimeFraction = 0.0; //!< 0..1
|
||||
CInterpolatorPbh m_pbh;
|
||||
CInterpolatorLinearPbh m_pbh;
|
||||
};
|
||||
|
||||
//! Get the interpolant for the given time point
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "blackmisc/simulation/interpolatorpbh.h"
|
||||
#include "blackmisc/simulation/interpolatorlinearpbh.h"
|
||||
#include "blackmisc/simulation/interpolatorfunctions.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
@@ -12,9 +12,9 @@ using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
CInterpolatorPbh::CInterpolatorPbh(double simulationTimeFraction, const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end) : m_simulationTimeFraction(simulationTimeFraction),
|
||||
m_startSituation(start),
|
||||
m_endSituation(end)
|
||||
CInterpolatorLinearPbh::CInterpolatorLinearPbh(double simulationTimeFraction, const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end) : m_simulationTimeFraction(simulationTimeFraction),
|
||||
m_startSituation(start),
|
||||
m_endSituation(end)
|
||||
{
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace BlackMisc::Simulation
|
||||
}
|
||||
}
|
||||
|
||||
CAngle CInterpolatorPbh::interpolateAngle(const CAngle &begin, const CAngle &end, double timeFraction0to1)
|
||||
CAngle CInterpolatorLinearPbh::interpolateAngle(const CAngle &begin, const CAngle &end, double timeFraction0to1)
|
||||
{
|
||||
// determine the right direction (to left, to right) we interpolate towards to
|
||||
// -30 -> 30 => 60 (via 0)
|
||||
@@ -44,7 +44,7 @@ namespace BlackMisc::Simulation
|
||||
return begin + CAngle(timeFraction0to1 * deltaDeg, CAngleUnit::deg());
|
||||
}
|
||||
|
||||
CHeading CInterpolatorPbh::getHeading() const
|
||||
CHeading CInterpolatorLinearPbh::getHeading() const
|
||||
{
|
||||
// HINT: VTOL aircraft can change pitch/bank without changing position, planes cannot
|
||||
// Interpolate heading: HDG = (HdgB - HdgA) * t + HdgA
|
||||
@@ -58,24 +58,24 @@ namespace BlackMisc::Simulation
|
||||
return CHeading(interpolateAngle(headingStart, headingEnd, m_simulationTimeFraction), headingEnd.getReferenceNorth());
|
||||
}
|
||||
|
||||
CAngle CInterpolatorPbh::getPitch() const
|
||||
CAngle CInterpolatorLinearPbh::getPitch() const
|
||||
{
|
||||
// Interpolate Pitch: Pitch = (PitchB - PitchA) * t + PitchA
|
||||
return interpolateAngle(m_startSituation.getPitch(), m_endSituation.getPitch(), m_simulationTimeFraction);
|
||||
}
|
||||
|
||||
CAngle CInterpolatorPbh::getBank() const
|
||||
CAngle CInterpolatorLinearPbh::getBank() const
|
||||
{
|
||||
// Interpolate bank: Bank = (BankB - BankA) * t + BankA
|
||||
return interpolateAngle(m_startSituation.getBank(), m_endSituation.getBank(), m_simulationTimeFraction);
|
||||
}
|
||||
|
||||
CSpeed CInterpolatorPbh::getGroundSpeed() const
|
||||
CSpeed CInterpolatorLinearPbh::getGroundSpeed() const
|
||||
{
|
||||
return (m_endSituation.getGroundSpeed() - m_startSituation.getGroundSpeed()) * m_simulationTimeFraction + m_startSituation.getGroundSpeed();
|
||||
}
|
||||
|
||||
void CInterpolatorPbh::setTimeFraction(double tf)
|
||||
void CInterpolatorLinearPbh::setTimeFraction(double tf)
|
||||
{
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATORLINEARPBH_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLATORLINEARPBH_H
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/heading.h"
|
||||
@@ -15,14 +15,14 @@
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
//! Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation
|
||||
class BLACKMISC_EXPORT CInterpolatorPbh
|
||||
class BLACKMISC_EXPORT CInterpolatorLinearPbh
|
||||
{
|
||||
public:
|
||||
//! @{
|
||||
//! Constructor
|
||||
CInterpolatorPbh() = default;
|
||||
CInterpolatorPbh(const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end) : m_startSituation(start), m_endSituation(end) {}
|
||||
CInterpolatorPbh(double simulationTimeFraction, const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end);
|
||||
CInterpolatorLinearPbh() = default;
|
||||
CInterpolatorLinearPbh(const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end) : m_startSituation(start), m_endSituation(end) {}
|
||||
CInterpolatorLinearPbh(double simulationTimeFraction, const Aviation::CAircraftSituation &start, const Aviation::CAircraftSituation &end);
|
||||
//! @}
|
||||
|
||||
//! @{
|
||||
@@ -226,7 +226,7 @@ namespace BlackMisc::Simulation
|
||||
m_nextSampleAdjustedTime = m_s[2].getAdjustedMSecsSinceEpoch(); // latest
|
||||
m_prevSampleTime = m_s[1].getMSecsSinceEpoch(); // last interpolated situation normally
|
||||
m_nextSampleTime = m_s[2].getMSecsSinceEpoch(); // latest
|
||||
m_interpolant = CInterpolant(pa, altUnit, CInterpolatorPbh(m_s[1], m_s[2])); // older, newer
|
||||
m_interpolant = CInterpolant(pa, altUnit, CInterpolatorLinearPbh(m_s[1], m_s[2])); // older, newer
|
||||
Q_ASSERT_X(m_prevSampleAdjustedTime < m_nextSampleAdjustedTime, Q_FUNC_INFO, "Wrong time order");
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace BlackMisc::Simulation
|
||||
return false;
|
||||
}
|
||||
|
||||
CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa, const CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh) : m_pa(pa), m_altitudeUnit(altitudeUnit)
|
||||
CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa, const CLengthUnit &altitudeUnit, const CInterpolatorLinearPbh &pbh) : m_pa(pa), m_altitudeUnit(altitudeUnit)
|
||||
{
|
||||
m_pbh = pbh;
|
||||
m_situationsAvailable = pa.size();
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BlackMisc::Simulation
|
||||
CInterpolant() : m_pa(PosArray::zeroPosArray()) {}
|
||||
|
||||
//! Constructor
|
||||
CInterpolant(const PosArray &pa, const PhysicalQuantities::CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh);
|
||||
CInterpolant(const PosArray &pa, const PhysicalQuantities::CLengthUnit &altitudeUnit, const CInterpolatorLinearPbh &pbh);
|
||||
|
||||
//! Perform the interpolation
|
||||
//! \param situation situation used as a base for interpolation. Contains for example the already interpolated PBH.
|
||||
@@ -77,13 +77,13 @@ namespace BlackMisc::Simulation
|
||||
//! \private UNIT tests/ASSERT only
|
||||
const PosArray &getPa() const { return m_pa; }
|
||||
|
||||
CInterpolatorPbh pbh() const { return m_pbh; }
|
||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
||||
|
||||
private:
|
||||
PosArray m_pa; //!< current positions array, latest values last
|
||||
PhysicalQuantities::CLengthUnit m_altitudeUnit;
|
||||
qint64 m_currentTimeMsSinceEpoc { -1 };
|
||||
CInterpolatorPbh m_pbh; //!< the used PBH interpolator
|
||||
CInterpolatorLinearPbh m_pbh; //!< the used PBH interpolator
|
||||
};
|
||||
|
||||
//! Strategy used by CInterpolator::getInterpolatedSituation
|
||||
|
||||
@@ -94,8 +94,8 @@ add_swift_test(
|
||||
)
|
||||
|
||||
add_swift_test(
|
||||
NAME misc_simulation_interpolatorpbh
|
||||
SOURCES simulation/testinterpolatorpbh/testinterpolatorpbh.cpp
|
||||
NAME misc_simulation_interpolatorlinearpbh
|
||||
SOURCES simulation/testinterpolatorlinearpbh/testinterpolatorlinearpbh.cpp
|
||||
LINK_LIBRARIES misc tests_test Qt::Core
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/heading.h"
|
||||
#include "blackmisc/simulation/interpolatorpbh.h"
|
||||
#include "blackmisc/simulation/interpolatorlinearpbh.h"
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackMiscTest
|
||||
{
|
||||
//! InterpolatorPBH tests
|
||||
//! As the PBH interpolator works with time-fractions, the situations are time-independent
|
||||
class CTestInterpolatorPbh : public QObject
|
||||
class CTestInterpolatorLinearPbh : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace BlackMiscTest
|
||||
static constexpr const double m_tfStep = 1.0 / m_steps; //!< Time fraction between steps
|
||||
};
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestHeading0To120()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeading0To120()
|
||||
{
|
||||
CAircraftSituation s1({}, CHeading(0, CHeading::True, CAngleUnit::deg()));
|
||||
CAircraftSituation s2({}, CHeading(120, CHeading::True, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -84,11 +84,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestHeadingM90To30()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeadingM90To30()
|
||||
{
|
||||
CAircraftSituation s1({}, CHeading(270, CHeading::True, CAngleUnit::deg())); // -90
|
||||
CAircraftSituation s2({}, CHeading(30, CHeading::True, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -113,11 +113,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestHeadingM90To170()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeadingM90To170()
|
||||
{
|
||||
CAircraftSituation s1({}, CHeading(270, CHeading::True, CAngleUnit::deg())); // -90
|
||||
CAircraftSituation s2({}, CHeading(170, CHeading::True, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -142,11 +142,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestBank270To30()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestBank270To30()
|
||||
{
|
||||
CAircraftSituation s1({}, CHeading {}, {}, CAngle(270, CAngleUnit::deg()));
|
||||
CAircraftSituation s2({}, CHeading {}, {}, CAngle(30, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -171,11 +171,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestBank170To190()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestBank170To190()
|
||||
{
|
||||
CAircraftSituation s1({}, CHeading {}, {}, CAngle(170, CAngleUnit::deg()));
|
||||
CAircraftSituation s2({}, CHeading {}, {}, CAngle(190, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -200,11 +200,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestPitch30ToM30()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestPitch30ToM30()
|
||||
{
|
||||
CAircraftSituation s1({}, {}, CAngle(30, CAngleUnit::deg()));
|
||||
CAircraftSituation s2({}, {}, CAngle(-30, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -229,11 +229,11 @@ namespace BlackMiscTest
|
||||
}
|
||||
}
|
||||
|
||||
void CTestInterpolatorPbh::pbhInterpolatorTestPitchM30To30()
|
||||
void CTestInterpolatorLinearPbh::pbhInterpolatorTestPitchM30To30()
|
||||
{
|
||||
CAircraftSituation s1({}, {}, CAngle(-30, CAngleUnit::deg()));
|
||||
CAircraftSituation s2({}, {}, CAngle(30, CAngleUnit::deg()));
|
||||
CInterpolatorPbh pbh(s1, s2);
|
||||
CInterpolatorLinearPbh pbh(s1, s2);
|
||||
|
||||
double lastDeg = 0;
|
||||
|
||||
@@ -260,8 +260,8 @@ namespace BlackMiscTest
|
||||
}
|
||||
|
||||
//! main
|
||||
BLACKTEST_MAIN(BlackMiscTest::CTestInterpolatorPbh);
|
||||
BLACKTEST_MAIN(BlackMiscTest::CTestInterpolatorLinearPbh);
|
||||
|
||||
#include "testinterpolatorpbh.moc"
|
||||
#include "testinterpolatorlinearpbh.moc"
|
||||
|
||||
//! \endcond
|
||||
Reference in New Issue
Block a user