18 using namespace swift::misc::aviation;
19 using namespace swift::misc::geo;
20 using namespace swift::misc::physical_quantities;
21 using namespace swift::misc::math;
22 using namespace swift::misc::simulation;
34 static void pbhInterpolatorTestHeading0To120();
37 static void pbhInterpolatorTestHeadingM90To30();
40 static void pbhInterpolatorTestHeadingM90To170();
43 static void pbhInterpolatorTestBank270To30();
46 static void pbhInterpolatorTestBank170To190();
49 static void pbhInterpolatorTestPitch30ToM30();
52 static void pbhInterpolatorTestPitchM30To30();
55 static constexpr
const int m_steps = 10;
56 static constexpr
const double m_tfStep = 1.0 / m_steps;
59 void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeading0To120()
67 for (
int i = 0; i <= m_steps; i++)
69 pbh.setTimeFraction(m_tfStep * i);
70 const double h = pbh.getHeading().value(CAngleUnit::deg());
72 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, 0.0),
"Expect initial heading"); }
73 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, 120.0),
"Expect final heading"); }
74 else { QVERIFY2(h > lastDeg,
"Expect increasing heading"); }
79 void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeadingM90To30()
87 for (
int i = 0; i <= m_steps; i++)
89 pbh.setTimeFraction(m_tfStep * i);
90 const double h = pbh.getHeading().value(CAngleUnit::deg());
92 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, -90.0),
"Expect initial heading"); }
93 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, 30.0),
"Expect final heading"); }
94 else { QVERIFY2(h > lastDeg,
"Expect increasing heading"); }
99 void CTestInterpolatorLinearPbh::pbhInterpolatorTestHeadingM90To170()
107 for (
int i = 0; i <= m_steps; i++)
109 pbh.setTimeFraction(m_tfStep * i);
110 const double h = CAngle::normalizeDegrees360(pbh.getHeading().value(CAngleUnit::deg()));
112 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, 270.0),
"Expect initial heading"); }
113 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(h, 170.0),
"Expect final heading"); }
114 else { QVERIFY2(h < lastDeg,
"Expect decreasing heading"); }
119 void CTestInterpolatorLinearPbh::pbhInterpolatorTestBank270To30()
127 for (
int i = 0; i <= m_steps; i++)
129 pbh.setTimeFraction(m_tfStep * i);
130 const double b = pbh.getBank().value(CAngleUnit::deg());
134 QVERIFY2(CMathUtils::epsilonEqualLimits(b, -90.0),
"Expect initial bank");
136 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(b, 30.0),
"Expect final bank"); }
137 else { QVERIFY2(b > lastDeg,
"Expect increasing bank"); }
142 void CTestInterpolatorLinearPbh::pbhInterpolatorTestBank170To190()
150 for (
int i = 0; i <= m_steps; i++)
152 pbh.setTimeFraction(m_tfStep * i);
153 const double b = CAngle::normalizeDegrees360(pbh.getBank().value(CAngleUnit::deg()));
155 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(b, 170.0),
"Expect initial bank"); }
156 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(b, 190.0),
"Expect final bank"); }
157 else { QVERIFY2(b > lastDeg,
"Expect increasing bank"); }
162 void CTestInterpolatorLinearPbh::pbhInterpolatorTestPitch30ToM30()
170 for (
int i = 0; i <= m_steps; i++)
172 pbh.setTimeFraction(m_tfStep * i);
173 const double p = pbh.getPitch().value(CAngleUnit::deg());
175 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(p, 30.0),
"Expect initial pitch"); }
176 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(p, -30.0),
"Expect final pitch"); }
177 else { QVERIFY2(p < lastDeg,
"Expect decreasing pitch"); }
182 void CTestInterpolatorLinearPbh::pbhInterpolatorTestPitchM30To30()
190 for (
int i = 0; i <= m_steps; i++)
192 pbh.setTimeFraction(m_tfStep * i);
193 const double p = pbh.getPitch().value(CAngleUnit::deg());
195 if (i == 0) { QVERIFY2(CMathUtils::epsilonEqualLimits(p, -30.0),
"Expect initial pitch"); }
196 else if (i == m_steps) { QVERIFY2(CMathUtils::epsilonEqualLimits(p, 30.0),
"Expect final pitch"); }
197 else { QVERIFY2(p > lastDeg,
"Expect increasing pitch"); }
206 #include "testinterpolatorlinearpbh.moc"
InterpolatorPBH tests As the PBH interpolator works with time-fractions, the situations are time-inde...
Value object encapsulating information of an aircraft's situation.
Heading as used in aviation, can be true or magnetic heading.
Physical unit angle (radians, degrees)
Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation.
Free functions in swift::misc.
SWIFTTEST_MAIN(MiscTest::CTestInterpolatorLinearPbh)
main