CLAMp and limits
This commit is contained in:
Binary file not shown.
+284
-443
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13
-8
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-3108
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user