From 47bc8a3abc23ec590e0e4bb741d4042527c38c9f Mon Sep 17 00:00:00 2001 From: Sean McLeod Date: Sat, 18 May 2024 17:06:27 +0200 Subject: [PATCH] Add support for setting ic/vw-mag-fps (#1093) --- src/initialization/FGInitialCondition.cpp | 5 +++-- src/initialization/FGInitialCondition.h | 6 +++++- tests/unit_tests/FGInitialConditionTest.h | 11 ++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/initialization/FGInitialCondition.cpp b/src/initialization/FGInitialCondition.cpp index e9f9094468..a0826ebdb8 100644 --- a/src/initialization/FGInitialCondition.cpp +++ b/src/initialization/FGInitialCondition.cpp @@ -936,7 +936,7 @@ FGColumnVector3 FGInitialCondition::GetWindNEDFpsIC(void) const { //****************************************************************************** -double FGInitialCondition::GetWindFpsIC(void) const +double FGInitialCondition::GetWindMagFpsIC(void) const { const FGMatrix33& Tb2l = orientation.GetTInv(); FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.); @@ -1519,7 +1519,8 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager) PropertyManager->Tie("ic/vw-down-fps", this, &FGInitialCondition::GetWindDFpsIC); PropertyManager->Tie("ic/vw-mag-fps", this, - &FGInitialCondition::GetWindFpsIC); + &FGInitialCondition::GetWindMagFpsIC, + &FGInitialCondition::SetWindMagFpsIC); PropertyManager->Tie("ic/vw-dir-deg", this, &FGInitialCondition::GetWindDirDegIC, &FGInitialCondition::SetWindDirDegIC); diff --git a/src/initialization/FGInitialCondition.h b/src/initialization/FGInitialCondition.h index 36065f7a7a..3b133428eb 100644 --- a/src/initialization/FGInitialCondition.h +++ b/src/initialization/FGInitialCondition.h @@ -443,6 +443,10 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase @param wD Initial wind velocity in local down direction, feet/second */ void SetWindNEDFpsIC(double wN, double wE, double wD); + /** Sets the initial total wind speed. + @param mag Initial wind velocity magnitude in feet/second */ + void SetWindMagFpsIC(double mag) { SetWindMagKtsIC(mag * fpstokts); } + /** Sets the initial total wind speed. @param mag Initial wind velocity magnitude in knots */ void SetWindMagKtsIC(double mag); @@ -505,7 +509,7 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase /** Gets the initial total wind velocity in feet/sec. @return Initial wind velocity in feet/second */ - double GetWindFpsIC(void) const; + double GetWindMagFpsIC(void) const; /** Gets the initial wind direction. @return Initial wind direction in feet/second */ diff --git a/tests/unit_tests/FGInitialConditionTest.h b/tests/unit_tests/FGInitialConditionTest.h index e38830868f..0e6606d046 100644 --- a/tests/unit_tests/FGInitialConditionTest.h +++ b/tests/unit_tests/FGInitialConditionTest.h @@ -52,7 +52,7 @@ class FGInitialConditionTest : public CxxTest::TestSuite TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0); TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0); TS_ASSERT_EQUALS(ic.GetBetaRadIC(), 0.0); - TS_ASSERT_EQUALS(ic.GetWindFpsIC(), 0.0); + TS_ASSERT_EQUALS(ic.GetWindMagFpsIC(), 0.0); TS_ASSERT_EQUALS(ic.GetWindDirDegIC(), 0.0); TS_ASSERT_EQUALS(ic.GetWindUFpsIC(), 0.0); TS_ASSERT_EQUALS(ic.GetWindVFpsIC(), 0.0); @@ -356,10 +356,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 1.0, epsilon); TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 2.0, epsilon); TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon); - TS_ASSERT_DELTA(ic.GetWindFpsIC(), sqrt(5.0), epsilon); + TS_ASSERT_DELTA(ic.GetWindMagFpsIC(), sqrt(5.0), epsilon); TS_ASSERT_DELTA(ic.GetWindDirDegIC(), atan2(2.0, 1.0)*180./M_PI, epsilon); - double mag = ic.GetWindFpsIC(); + double mag = ic.GetWindMagFpsIC(); ic.SetWindDirDegIC(30.); TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 0.5*mag*sqrt(3.0), epsilon); TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 0.5*mag, epsilon); @@ -369,5 +369,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5*sqrt(3.0)*ktstofps, epsilon); TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5*ktstofps, epsilon); TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon); + + ic.SetWindMagFpsIC(7.0); + TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5 * sqrt(3.0), epsilon); + TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5, epsilon); + TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon); } };