PageCurrent: Limit leeway size when STW is too small

This commit is contained in:
Ulrich Meine
2026-07-23 00:07:17 +02:00
parent 88dfa84cc8
commit eaa1f793ff
+6 -3
View File
@@ -106,12 +106,15 @@ private:
double stw // speed through water (m/s) double stw // speed through water (m/s)
) )
{ {
if (stw == 0) { static constexpr double MINSTW = 0.5; // minimum speed (m/s) for leeway calculation to prevent math explosion
return 0; static constexpr double MAXLAY = 30.0 * DEG_TO_RAD; // cap leeway at this level of degree;
if (stw < MINSTW) {
return 0;
} }
double lay = leeK * roll / (stw * stw); double lay = leeK * roll / (stw * stw);
return lay; return std::min(lay, MAXLAY);
} }
double calcCTW( double calcCTW(