mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T231, utility functions
* corrected altitude also considering CG * 0 if CG is NULL
This commit is contained in:
@@ -214,11 +214,13 @@ namespace BlackMisc
|
||||
return this->getAltitude() - gh;
|
||||
}
|
||||
|
||||
CAltitude CAircraftSituation::getCorrectedAltitude() const
|
||||
CAltitude CAircraftSituation::getCorrectedAltitude(const CLength ¢erOfGravity) const
|
||||
{
|
||||
if (this->getGroundElevation().isNull()) { return this->getAltitude(); }
|
||||
if (this->getAltitude().getReferenceDatum() != CAltitude::MeanSeaLevel) { return this->getAltitude(); }
|
||||
if (this->getGroundElevation() < this->getAltitude()) { return this->getAltitude(); }
|
||||
CAltitude altPlusCG = this->getAltitude();
|
||||
if (!centerOfGravity.isNull()) { altPlusCG += centerOfGravity; }
|
||||
if (this->getGroundElevation().isNull()) { return altPlusCG; }
|
||||
if (this->getAltitude().getReferenceDatum() != CAltitude::MeanSeaLevel) { return altPlusCG; }
|
||||
if (this->getGroundElevation() < this->getAltitude()) { return altPlusCG; }
|
||||
return this->getGroundElevation();
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace BlackMisc
|
||||
const CAltitude &getAltitude() const { return m_position.geodeticHeight(); }
|
||||
|
||||
//! Get altitude under consideration of ground elevation
|
||||
CAltitude getCorrectedAltitude() const;
|
||||
CAltitude getCorrectedAltitude(const PhysicalQuantities::CLength ¢erOfGravity = {}) const;
|
||||
|
||||
//! Set altitude
|
||||
void setAltitude(const CAltitude &altitude) { m_position.setGeodeticHeight(altitude); }
|
||||
|
||||
@@ -45,6 +45,12 @@ namespace BlackMisc
|
||||
return m_elevationPlane.isWithinRange(coordinate);
|
||||
}
|
||||
|
||||
const CLength &CInterpolationHints::getCGAboveGroundOrZero() const
|
||||
{
|
||||
static const CLength zero;
|
||||
return this->hasCGAboveGround() ? this->getCGAboveGround() : zero;
|
||||
}
|
||||
|
||||
void CInterpolationHints::setAircraftParts(const CAircraftParts &parts, bool hasParts)
|
||||
{
|
||||
m_hasParts = hasParts;
|
||||
|
||||
@@ -66,6 +66,9 @@ namespace BlackMisc
|
||||
//! Get CG above ground
|
||||
const PhysicalQuantities::CLength &getCGAboveGround() const { return m_cgAboveGround;}
|
||||
|
||||
//! Get CG above ground or 0 ("Zero")
|
||||
const PhysicalQuantities::CLength &getCGAboveGroundOrZero() const;
|
||||
|
||||
//! Has CG above ground
|
||||
bool hasCGAboveGround() const { return m_cgAboveGround.isNull(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user