Skip to content

Commit 47bc8a3

Browse files
authored
Add support for setting ic/vw-mag-fps (#1093)
1 parent 56c6662 commit 47bc8a3

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/initialization/FGInitialCondition.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ FGColumnVector3 FGInitialCondition::GetWindNEDFpsIC(void) const {
936936

937937
//******************************************************************************
938938

939-
double FGInitialCondition::GetWindFpsIC(void) const
939+
double FGInitialCondition::GetWindMagFpsIC(void) const
940940
{
941941
const FGMatrix33& Tb2l = orientation.GetTInv();
942942
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
@@ -1519,7 +1519,8 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager)
15191519
PropertyManager->Tie("ic/vw-down-fps", this,
15201520
&FGInitialCondition::GetWindDFpsIC);
15211521
PropertyManager->Tie("ic/vw-mag-fps", this,
1522-
&FGInitialCondition::GetWindFpsIC);
1522+
&FGInitialCondition::GetWindMagFpsIC,
1523+
&FGInitialCondition::SetWindMagFpsIC);
15231524
PropertyManager->Tie("ic/vw-dir-deg", this,
15241525
&FGInitialCondition::GetWindDirDegIC,
15251526
&FGInitialCondition::SetWindDirDegIC);

src/initialization/FGInitialCondition.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase
443443
@param wD Initial wind velocity in local down direction, feet/second */
444444
void SetWindNEDFpsIC(double wN, double wE, double wD);
445445

446+
/** Sets the initial total wind speed.
447+
@param mag Initial wind velocity magnitude in feet/second */
448+
void SetWindMagFpsIC(double mag) { SetWindMagKtsIC(mag * fpstokts); }
449+
446450
/** Sets the initial total wind speed.
447451
@param mag Initial wind velocity magnitude in knots */
448452
void SetWindMagKtsIC(double mag);
@@ -505,7 +509,7 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase
505509

506510
/** Gets the initial total wind velocity in feet/sec.
507511
@return Initial wind velocity in feet/second */
508-
double GetWindFpsIC(void) const;
512+
double GetWindMagFpsIC(void) const;
509513

510514
/** Gets the initial wind direction.
511515
@return Initial wind direction in feet/second */

tests/unit_tests/FGInitialConditionTest.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FGInitialConditionTest : public CxxTest::TestSuite
5252
TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0);
5353
TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0);
5454
TS_ASSERT_EQUALS(ic.GetBetaRadIC(), 0.0);
55-
TS_ASSERT_EQUALS(ic.GetWindFpsIC(), 0.0);
55+
TS_ASSERT_EQUALS(ic.GetWindMagFpsIC(), 0.0);
5656
TS_ASSERT_EQUALS(ic.GetWindDirDegIC(), 0.0);
5757
TS_ASSERT_EQUALS(ic.GetWindUFpsIC(), 0.0);
5858
TS_ASSERT_EQUALS(ic.GetWindVFpsIC(), 0.0);
@@ -356,10 +356,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite
356356
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 1.0, epsilon);
357357
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 2.0, epsilon);
358358
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);
359-
TS_ASSERT_DELTA(ic.GetWindFpsIC(), sqrt(5.0), epsilon);
359+
TS_ASSERT_DELTA(ic.GetWindMagFpsIC(), sqrt(5.0), epsilon);
360360
TS_ASSERT_DELTA(ic.GetWindDirDegIC(), atan2(2.0, 1.0)*180./M_PI, epsilon);
361361

362-
double mag = ic.GetWindFpsIC();
362+
double mag = ic.GetWindMagFpsIC();
363363
ic.SetWindDirDegIC(30.);
364364
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 0.5*mag*sqrt(3.0), epsilon);
365365
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 0.5*mag, epsilon);
@@ -369,5 +369,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite
369369
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5*sqrt(3.0)*ktstofps, epsilon);
370370
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5*ktstofps, epsilon);
371371
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);
372+
373+
ic.SetWindMagFpsIC(7.0);
374+
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5 * sqrt(3.0), epsilon);
375+
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5, epsilon);
376+
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);
372377
}
373378
};

0 commit comments

Comments
 (0)