swift
Loading...
Searching...
No Matches
interpolatorspline.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATORSPLINE_H
7#define SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATORSPLINE_H
8
14
15namespace swift::misc::simulation
16{
19 {
20 void anchor() override;
21
22 public:
25 IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *aircraftProvider,
26 CInterpolationLogger *logger = nullptr)
27 : CInterpolator(callsign, envProvider, setupProvider, aircraftProvider, logger)
28 {}
29
32 {
34 void initToZero();
35
37 static const PosArray &zeroPosArray();
38
41 std::array<double, 3> x;
42 std::array<double, 3> y;
43 std::array<double, 3> z;
44 std::array<double, 3> a;
45 std::array<double, 3> gnd;
46 std::array<double, 3> t;
47 std::array<double, 3> dx;
48 std::array<double, 3> dy;
49 std::array<double, 3> dz;
50 std::array<double, 3> da;
51 std::array<double, 3> dgnd;
53
55 int size() const { return static_cast<int>(x.size()); }
56 };
57
60 {
61 public:
63 CInterpolant() : m_pa(PosArray::zeroPosArray()) {}
64
66 CInterpolant(const PosArray &pa, const physical_quantities::CLengthUnit &altitudeUnit,
67 const CInterpolatorLinearPbh &pbh);
68
70 std::tuple<geo::CCoordinateGeodetic, aviation::CAltitude> interpolatePositionAndAltitude() const override;
71
73 aviation::COnGroundInfo interpolateGroundFactor() const override;
74
76 void setTimes(qint64 currentTimeMs, double timeFraction, qint64 interpolatedTimeMs);
77
79 const PosArray &getPa() const { return m_pa; }
80
82 const IInterpolatorPbh &pbh() const override { return m_pbh; }
83
84 private:
85 PosArray m_pa;
87 qint64 m_currentTimeMsSinceEpoc { -1 };
89 };
90
92 const IInterpolant &getInterpolant(SituationLog &log) override;
93
94 private:
96 bool updateElevations(bool canSkip);
97
99 bool areAnyElevationsMissing() const;
100
102 bool isAnySituationNearGroundRelevant() const;
103
105 bool fillSituationsArray();
106
108 static bool verifyInterpolationSituations(const aviation::CAircraftSituation &oldest,
109 const aviation::CAircraftSituation &newer,
110 const aviation::CAircraftSituation &latest,
111 const CInterpolationAndRenderingSetupPerCallsign &setup =
112 CInterpolationAndRenderingSetupPerCallsign::null());
113
114 qint64 m_prevSampleAdjustedTime = 0;
115 qint64 m_nextSampleAdjustedTime = 0;
116 qint64 m_prevSampleTime = 0;
117 qint64 m_nextSampleTime = 0;
118 std::array<aviation::CAircraftSituation, 3> m_s;
119 CInterpolant m_interpolant;
120 };
121} // namespace swift::misc::simulation
122
123#endif // SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATORSPLINE_H
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Definition callsign.h:30
Information about the ground status.
Specialized class for distance units (meter, foot, nautical miles).
Definition units.h:95
Record internal state of interpolator for debugging.
CInterpolator(const aviation::CCallsign &callsign, ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider, CInterpolationLogger *logger)
Constructor.
Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation.
Cubic function that performs the actual interpolation.
const IInterpolatorPbh & pbh() const
Get the PBH interpolator.
CInterpolatorSpline(const aviation::CCallsign &callsign, ISimulationEnvironmentProvider *envProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *aircraftProvider, CInterpolationLogger *logger=nullptr)
Constructor.
IInterpolant()=default
Default ctor.
Direct in memory access to interpolation setup, normally implemented by simulator.
Base class for Pitch-Bank-Heading interpolators.
Direct thread safe in memory access to remote aircraft.
std::array< double, 3 > dz
3 coordinates for spline interpolation
std::array< double, 3 > dx
3 coordinates for spline interpolation
static const PosArray & zeroPosArray()
Zero initialized position array.
std::array< double, 3 > a
3 coordinates for spline interpolation
std::array< double, 3 > y
3 coordinates for spline interpolation
std::array< double, 3 > t
3 coordinates for spline interpolation
std::array< double, 3 > x
3 coordinates for spline interpolation
std::array< double, 3 > gnd
3 coordinates for spline interpolation
std::array< double, 3 > dgnd
3 coordinates for spline interpolation
std::array< double, 3 > z
3 coordinates for spline interpolation
std::array< double, 3 > dy
3 coordinates for spline interpolation
std::array< double, 3 > da
3 coordinates for spline interpolation
#define SWIFT_MISC_EXPORT
Export a class or function from the library.