From eaa1f793ff7a28085c540c0553e114abf1a81c54 Mon Sep 17 00:00:00 2001 From: Ulrich Meine <145987006+Scorgan01@users.noreply.github.com> Date: Thu, 23 Jul 2026 00:07:17 +0200 Subject: [PATCH] PageCurrent: Limit leeway size when STW is too small --- lib/obp60task/PageCurrent.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/obp60task/PageCurrent.cpp b/lib/obp60task/PageCurrent.cpp index 4af8a79..15820af 100644 --- a/lib/obp60task/PageCurrent.cpp +++ b/lib/obp60task/PageCurrent.cpp @@ -106,12 +106,15 @@ private: double stw // speed through water (m/s) ) { - if (stw == 0) { - return 0; + static constexpr double MINSTW = 0.5; // minimum speed (m/s) for leeway calculation to prevent math explosion + 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); - return lay; + return std::min(lay, MAXLAY); } double calcCTW(