FlightGear next
AircraftPerformance.hxx
Go to the documentation of this file.
1// AircraftPerformance.hxx - compute data about planned acft performance
2//
3// Copyright (C) 2018 James Turner <james@flightgear.org>
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License as
6// published by the Free Software Foundation; either version 2 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18#ifndef AIRCRAFTPERFORMANCE_HXX
19#define AIRCRAFTPERFORMANCE_HXX
20
21#include <string>
22#include <vector>
23#include <functional>
24
25namespace flightgear
26{
27
28const char ICAO_AIRCRAFT_CATEGORY_A = 'A';
29const char ICAO_AIRCRAFT_CATEGORY_B = 'B';
30const char ICAO_AIRCRAFT_CATEGORY_C = 'C';
31const char ICAO_AIRCRAFT_CATEGORY_D = 'D';
32const char ICAO_AIRCRAFT_CATEGORY_E = 'E';
33
40{
41public:
43
44 double turnRateDegSec() const;
45
46 double turnRadiusMForAltitude(int altitudeFt) const;
47
48 double groundSpeedForAltitudeKnots(int altitudeFt) const;
49
50 int computePreviousAltitude(double distanceM, int targetAltFt) const;
51 int computeNextAltitude(double distanceM, int initialAltFt) const;
52
53 double distanceNmBetween(int initialElevationFt, int targetElevationFt) const;
54 double timeBetween(int initialElevationFt, int targetElevationFt) const;
55
56 double timeToCruise(double cruiseDistanceNm, int cruiseAltitudeFt) const;
57
58 static double groundSpeedForCAS(int altitudeFt, double cas);
59 static double machForCAS(int altitudeFt, double cas);
60 static double groundSpeedForMach(int altitudeFt, double mach);
61
62private:
63 void readPerformanceData();
64
65 void icaoCategoryData();
66
73 std::string heuristicCatergoryFromTags() const;
74
75 class Bracket
76 {
77 public:
78 Bracket(int atOrBelow, int climb, int descent, double speed, bool isMach = false) :
79 atOrBelowAltitudeFt(atOrBelow),
80 climbRateFPM(climb),
81 descentRateFPM(descent),
82 speedIASOrMach(speed),
83 speedIsMach(isMach)
84 { }
85
86 int gsForAltitude(int altitude) const;
87
88 double climbTime(int alt1, int alt2) const;
89 double climbDistanceM(int alt1, int alt2) const;
90 double descendTime(int alt1, int alt2) const;
91 double descendDistanceM(int alt1, int alt2) const;
92
93 int atOrBelowAltitudeFt;
94 int climbRateFPM;
95 int descentRateFPM;
96 double speedIASOrMach;
97 bool speedIsMach = false;
98 };
99
100 using PerformanceVec = std::vector<Bracket>;
101
102 using BracketRange = std::pair<PerformanceVec::const_iterator, PerformanceVec::const_iterator>;
103
104 PerformanceVec::const_iterator bracketForAltitude(int altitude) const;
105 BracketRange rangeForAltitude(int lowAltitude, int highAltitude) const;
106
107
108 using TraversalFunc = std::function<void(const Bracket& bk, int alt1, int alt2)>;
109 void traverseAltitudeRange(int initialElevationFt, int targetElevationFt, TraversalFunc tf) const;
110
111
112 PerformanceVec _perfData;
113};
114
115}
116
117#endif // AIRCRAFTPERFORMANCE_HXX
double altitude
Definition ADA.cxx:46
static double groundSpeedForCAS(int altitudeFt, double cas)
static double groundSpeedForMach(int altitudeFt, double mach)
double timeBetween(int initialElevationFt, int targetElevationFt) const
double groundSpeedForAltitudeKnots(int altitudeFt) const
int computeNextAltitude(double distanceM, int initialAltFt) const
double distanceNmBetween(int initialElevationFt, int targetElevationFt) const
double timeToCruise(double cruiseDistanceNm, int cruiseAltitudeFt) const
int computePreviousAltitude(double distanceM, int targetAltFt) const
static double machForCAS(int altitudeFt, double cas)
double turnRadiusMForAltitude(int altitudeFt) const
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
const char ICAO_AIRCRAFT_CATEGORY_B
const char ICAO_AIRCRAFT_CATEGORY_E
const char ICAO_AIRCRAFT_CATEGORY_C
const char ICAO_AIRCRAFT_CATEGORY_A
const char ICAO_AIRCRAFT_CATEGORY_D