Skip to content

Commit

Permalink
Add support for setting ic/vw-mag-fps (JSBSim-Team#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcleod authored May 18, 2024
1 parent 56c6662 commit 47bc8a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/initialization/FGInitialCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/initialization/FGInitialCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
11 changes: 8 additions & 3 deletions tests/unit_tests/FGInitialConditionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
};

0 comments on commit 47bc8a3

Please sign in to comment.