CLAMp and limits
This commit is contained in:
+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.87.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <tuple>
|
||||
|
||||
@@ -97,19 +98,23 @@ float interp(float lower, float upper, float ratio) {
|
||||
/// @brief Calculate mach for a given CI and aircraft state
|
||||
/// @param altitude Altitude in feet
|
||||
/// @param weight Weight in kilogrammes
|
||||
/// @param totalFuel Total fuel in kilogrammes
|
||||
/// @param totalFuel Total fuel in kilogrammes EXCLUDING BALLAST
|
||||
/// @param ci CI
|
||||
/// @return Mach corresponding to CI. Returns -1 if not possible
|
||||
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 lowerFl = std::get<0>(bAlt);
|
||||
auto upperFl = std::get<1>(bAlt);
|
||||
auto ratioFl = std::get<2>(bAlt);
|
||||
int lowerFl = std::get<0>(bAlt);
|
||||
int upperFl = std::get<1>(bAlt);
|
||||
float ratioFl = std::get<2>(bAlt);
|
||||
|
||||
auto bWgt = boundWeight(weight);
|
||||
auto lowerWgt = std::get<0>(bWgt);
|
||||
auto upperWgt = std::get<1>(bWgt);
|
||||
auto ratioWgt = std::get<2>(bWgt);
|
||||
int lowerWgt = std::get<0>(bWgt);
|
||||
int upperWgt = std::get<1>(bWgt);
|
||||
float ratioWgt = std::get<2>(bWgt);
|
||||
|
||||
float ratioMMO = boundMMO(totalFuel);
|
||||
|
||||
@@ -124,7 +129,7 @@ float ci2mach(float altitude, float weight, float totalFuel, int ci) {
|
||||
int upperWgtIndex = weight2Index(upperWgt);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user