refactor: Split position/altitude and groundfactor interpolation

This commit is contained in:
Lars Toenning
2024-01-09 09:37:36 +01:00
parent a27c2b3f51
commit 8253b73db2
5 changed files with 64 additions and 46 deletions

View File

@@ -45,7 +45,7 @@ namespace BlackMisc::Simulation
void CInterpolatorLinear::anchor()
{}
CAircraftSituation CInterpolatorLinear::CInterpolant::interpolatePositionAndAltitude(const CAircraftSituation &situation, bool interpolateGndFactor) const
CAircraftSituation CInterpolatorLinear::CInterpolant::interpolatePositionAndAltitude(const CAircraftSituation &situation) const
{
const std::array<double, 3> startVec(m_startSituation.getPosition().normalVectorDouble());
const std::array<double, 3> endVec(m_endSituation.getPosition().normalVectorDouble());
@@ -82,27 +82,29 @@ namespace BlackMisc::Simulation
interpolatedSituation.setAltitude(altitude);
interpolatedSituation.setMSecsSinceEpoch(this->getInterpolatedTime());
if (interpolateGndFactor)
{
const double startGroundFactor = m_startSituation.getOnGroundInfo().getGroundFactor();
const double endGroundFactor = m_endSituation.getOnGroundInfo().getGroundFactor();
if (CAircraftSituation::isGfEqualAirborne(startGroundFactor, endGroundFactor))
{
interpolatedSituation.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::OnGroundByInterpolation });
}
else if (CAircraftSituation::isGfEqualOnGround(startGroundFactor, endGroundFactor))
{
interpolatedSituation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByInterpolation });
}
else
{
const double interpolatedGroundFactor = (endGroundFactor - startGroundFactor) * tf + startGroundFactor;
interpolatedSituation.setOnGroundInfo(COnGroundInfo(interpolatedGroundFactor));
}
}
return interpolatedSituation;
}
Aviation::COnGroundInfo CInterpolatorLinear::CInterpolant::interpolateGroundFactor() const
{
const double startGroundFactor = m_startSituation.getOnGroundInfo().getGroundFactor();
const double endGroundFactor = m_endSituation.getOnGroundInfo().getGroundFactor();
if (CAircraftSituation::isGfEqualAirborne(startGroundFactor, endGroundFactor))
{
return { COnGroundInfo::NotOnGround, COnGroundInfo::OnGroundByInterpolation };
}
else if (CAircraftSituation::isGfEqualOnGround(startGroundFactor, endGroundFactor))
{
return { COnGroundInfo::OnGround, COnGroundInfo::OnGroundByInterpolation };
}
else
{
const double tf = clampValidTimeFraction(m_simulationTimeFraction);
const double interpolatedGroundFactor = (endGroundFactor - startGroundFactor) * tf + startGroundFactor;
return COnGroundInfo(interpolatedGroundFactor);
}
}
CInterpolatorLinear::CInterpolant CInterpolatorLinear::getInterpolant(SituationLog &log)
{
// set default situations