mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Add interface for PBH interpolators
This commit is contained in:
@@ -648,6 +648,7 @@ add_library(misc SHARED
|
||||
simulation/simulatedaircraftlist.cpp
|
||||
simulation/matchingstatisticsentry.h
|
||||
simulation/interpolationsetuplist.h
|
||||
simulation/interpolatorpbh.h
|
||||
|
||||
# Test
|
||||
test/testdata.cpp
|
||||
|
||||
@@ -246,11 +246,12 @@ namespace BlackMisc::Simulation
|
||||
{
|
||||
if (!isValidInterpolant) { break; }
|
||||
|
||||
const IInterpolatorPbh &pbh = interpolant.pbh();
|
||||
|
||||
// init interpolated situation
|
||||
currentSituation = this->initInterpolatedSituation(pbh.getStartSituation(), pbh.getEndSituation());
|
||||
|
||||
// Pitch bank heading first, so follow up steps could use those values
|
||||
const auto pbh = interpolant.pbh();
|
||||
currentSituation.setHeading(pbh.getHeading());
|
||||
currentSituation.setPitch(pbh.getPitch());
|
||||
currentSituation.setBank(pbh.getBank());
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
||||
//! End situation
|
||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
||||
|
||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
||||
const IInterpolatorPbh &pbh() const { return m_pbh; }
|
||||
|
||||
private:
|
||||
Aviation::CAircraftSituation m_startSituation;
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/interpolatorpbh.h"
|
||||
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
//! Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation
|
||||
class BLACKMISC_EXPORT CInterpolatorLinearPbh
|
||||
class BLACKMISC_EXPORT CInterpolatorLinearPbh : public IInterpolatorPbh
|
||||
{
|
||||
public:
|
||||
//! @{
|
||||
@@ -27,12 +28,12 @@ namespace BlackMisc::Simulation
|
||||
|
||||
//! @{
|
||||
//! Getter
|
||||
Aviation::CHeading getHeading() const;
|
||||
PhysicalQuantities::CAngle getPitch() const;
|
||||
PhysicalQuantities::CAngle getBank() const;
|
||||
PhysicalQuantities::CSpeed getGroundSpeed() const;
|
||||
const Aviation::CAircraftSituation &getStartSituation() const { return m_startSituation; }
|
||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
||||
Aviation::CHeading getHeading() const override;
|
||||
PhysicalQuantities::CAngle getPitch() const override;
|
||||
PhysicalQuantities::CAngle getBank() const override;
|
||||
PhysicalQuantities::CSpeed getGroundSpeed() const override;
|
||||
const Aviation::CAircraftSituation &getStartSituation() const override { return m_startSituation; }
|
||||
const Aviation::CAircraftSituation &getEndSituation() const override { return m_endSituation; }
|
||||
//! @}
|
||||
|
||||
//! Change time fraction
|
||||
|
||||
34
src/blackmisc/simulation/interpolatorpbh.h
Normal file
34
src/blackmisc/simulation/interpolatorpbh.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||
|
||||
#include "blackmisc/aviation/heading.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
//! Base class for Pitch-Bank-Heading interpolators
|
||||
class IInterpolatorPbh
|
||||
{
|
||||
public:
|
||||
virtual ~IInterpolatorPbh() = default;
|
||||
|
||||
//! @{
|
||||
//! Getter
|
||||
virtual Aviation::CHeading getHeading() const = 0;
|
||||
virtual PhysicalQuantities::CAngle getPitch() const = 0;
|
||||
virtual PhysicalQuantities::CAngle getBank() const = 0;
|
||||
virtual PhysicalQuantities::CSpeed getGroundSpeed() const = 0;
|
||||
virtual const Aviation::CAircraftSituation &getStartSituation() const = 0;
|
||||
virtual const Aviation::CAircraftSituation &getEndSituation() const = 0;
|
||||
//! @}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||
@@ -77,7 +77,7 @@ namespace BlackMisc::Simulation
|
||||
//! \private UNIT tests/ASSERT only
|
||||
const PosArray &getPa() const { return m_pa; }
|
||||
|
||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
||||
const IInterpolatorPbh &pbh() const { return m_pbh; }
|
||||
|
||||
private:
|
||||
PosArray m_pa; //!< current positions array, latest values last
|
||||
|
||||
Reference in New Issue
Block a user