CLAMp and limits
This commit is contained in:
parent
6967836c8a
commit
02a9460c83
BIN
Docs/MD11-ECON-CRZ v4.pdf
Normal file
BIN
Docs/MD11-ECON-CRZ v4.pdf
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
V4/demo/demo.exe
BIN
V4/demo/demo.exe
Binary file not shown.
BIN
V4/demo/demo.ilk
BIN
V4/demo/demo.ilk
Binary file not shown.
BIN
V4/demo/demo.obj
BIN
V4/demo/demo.obj
Binary file not shown.
BIN
V4/demo/demo.pdb
BIN
V4/demo/demo.pdb
Binary file not shown.
Binary file not shown.
21
V4/econSpd.h
21
V4/econSpd.h
@ -23,6 +23,7 @@
|
|||||||
#include "ci2mach_0.85.h"
|
#include "ci2mach_0.85.h"
|
||||||
#include "ci2mach_0.87.h"
|
#include "ci2mach_0.87.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
@ -97,19 +98,23 @@ float interp(float lower, float upper, float ratio) {
|
|||||||
/// @brief Calculate mach for a given CI and aircraft state
|
/// @brief Calculate mach for a given CI and aircraft state
|
||||||
/// @param altitude Altitude in feet
|
/// @param altitude Altitude in feet
|
||||||
/// @param weight Weight in kilogrammes
|
/// @param weight Weight in kilogrammes
|
||||||
/// @param totalFuel Total fuel in kilogrammes
|
/// @param totalFuel Total fuel in kilogrammes EXCLUDING BALLAST
|
||||||
/// @param ci CI
|
/// @param ci CI
|
||||||
/// @return Mach corresponding to CI. Returns -1 if not possible
|
/// @return Mach corresponding to CI. Returns -1 if not possible
|
||||||
float ci2mach(float altitude, float weight, float totalFuel, int ci) {
|
float ci2mach(float altitude, float weight, float totalFuel, int ci) {
|
||||||
|
// Some fallback assumptions for extreme cases
|
||||||
|
weight = std::clamp(weight, 140000.0f, 290000.0f);
|
||||||
|
altitude = std::min(altitude, 43000.0f);
|
||||||
|
|
||||||
auto bAlt = boundAltitude(altitude);
|
auto bAlt = boundAltitude(altitude);
|
||||||
auto lowerFl = std::get<0>(bAlt);
|
int lowerFl = std::get<0>(bAlt);
|
||||||
auto upperFl = std::get<1>(bAlt);
|
int upperFl = std::get<1>(bAlt);
|
||||||
auto ratioFl = std::get<2>(bAlt);
|
float ratioFl = std::get<2>(bAlt);
|
||||||
|
|
||||||
auto bWgt = boundWeight(weight);
|
auto bWgt = boundWeight(weight);
|
||||||
auto lowerWgt = std::get<0>(bWgt);
|
int lowerWgt = std::get<0>(bWgt);
|
||||||
auto upperWgt = std::get<1>(bWgt);
|
int upperWgt = std::get<1>(bWgt);
|
||||||
auto ratioWgt = std::get<2>(bWgt);
|
float ratioWgt = std::get<2>(bWgt);
|
||||||
|
|
||||||
float ratioMMO = boundMMO(totalFuel);
|
float ratioMMO = boundMMO(totalFuel);
|
||||||
|
|
||||||
@ -124,7 +129,7 @@ float ci2mach(float altitude, float weight, float totalFuel, int ci) {
|
|||||||
int upperWgtIndex = weight2Index(upperWgt);
|
int upperWgtIndex = weight2Index(upperWgt);
|
||||||
|
|
||||||
// Outside of the maximum indicies
|
// Outside of the maximum indicies
|
||||||
if (lowerFlIndex > 10 || upperFlIndex > 10 || lowerWgtIndex > 16 || upperWgtIndex > 16) {
|
if (lowerFlIndex > 9 || upperFlIndex > 9 || lowerWgtIndex > 15 || upperWgtIndex > 15) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user