Line data Source code
1 : /* SpeedToFly class by Samuel Tabor, 2021. 2 : 3 : Calculates the optimal speed to fly given drag polar, expected climb rate in next thermal and 4 : horizontal and vertical air movement between thermals. 5 : */ 6 : #pragma once 7 : 8 : #include "Variometer.h" 9 : 10 : class SpeedToFly { 11 : 12 : float _CL_estimate = -1.0f; 13 : 14 : const Variometer::PolarParams &_polarParams; 15 : 16 : public: 17 692 : SpeedToFly(const Variometer::PolarParams &polarParams) :_polarParams(polarParams) {} 18 : 19 : void update(float Wx, float Wz, float Wexp, float CLmin, float CLmax); 20 : 21 34752 : float speed_to_fly(void) {return _CL_estimate>0 ? sqrtf(_polarParams.K/_CL_estimate) : -1.0f;}; 22 : };