mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refactor: Rename CInterpolatorPbh to CInterpolatorLinearPbh
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user