mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Ref T505, heading normalize
This commit is contained in:
committed by
Mat Sutcliffe
parent
b476ce4894
commit
8bd6fdf9fc
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/aviation/heading.h"
|
#include "blackmisc/aviation/heading.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using BlackMisc::PhysicalQuantities::CAngle;
|
using BlackMisc::PhysicalQuantities::CAngle;
|
||||||
@@ -22,11 +21,19 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return i18n ?
|
return i18n ?
|
||||||
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
||||||
this->isMagneticHeading() ?
|
this->isMagneticHeading() ?
|
||||||
QCoreApplication::translate("Aviation", "magnetic") :
|
QCoreApplication::translate("Aviation", "magnetic") :
|
||||||
QCoreApplication::translate("Aviation", "true")) :
|
QCoreApplication::translate("Aviation", "true")) :
|
||||||
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
||||||
this->isMagneticHeading() ? "magnetic" : "true");
|
this->isMagneticHeading() ? "magnetic" : "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHeading::normalizeTo360Degrees()
|
||||||
|
{
|
||||||
|
const double v = normalizeDegrees360(this->value(CAngleUnit::deg()));
|
||||||
|
const CAngleUnit u = this->getUnit();
|
||||||
|
*this = CHeading(v, this->getReferenceNorth(), CAngleUnit::deg());
|
||||||
|
this->switchUnit(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeading::normalizeToPlusMinus180Degrees()
|
void CHeading::normalizeToPlusMinus180Degrees()
|
||||||
@@ -44,6 +51,13 @@ namespace BlackMisc
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHeading CHeading::normalizedTo360Degrees() const
|
||||||
|
{
|
||||||
|
CHeading copy(*this);
|
||||||
|
copy.normalizeTo360Degrees();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
void CHeading::registerMetadata()
|
void CHeading::registerMetadata()
|
||||||
{
|
{
|
||||||
Mixin::MetaType<CHeading>::registerMetadata();
|
Mixin::MetaType<CHeading>::registerMetadata();
|
||||||
|
|||||||
@@ -87,12 +87,18 @@ namespace BlackMisc
|
|||||||
//! Get reference north (magnetic or true)
|
//! Get reference north (magnetic or true)
|
||||||
ReferenceNorth getReferenceNorth() const { return m_north; }
|
ReferenceNorth getReferenceNorth() const { return m_north; }
|
||||||
|
|
||||||
|
//! Normalize to [0, 359.99]
|
||||||
|
void normalizeTo360Degrees();
|
||||||
|
|
||||||
//! Normalize to +- 180deg, [-179.99, 180.0]
|
//! Normalize to +- 180deg, [-179.99, 180.0]
|
||||||
void normalizeToPlusMinus180Degrees();
|
void normalizeToPlusMinus180Degrees();
|
||||||
|
|
||||||
//! As [-179.99, 180.0] normalized heading
|
//! As [-179.99, 180.0] normalized heading
|
||||||
CHeading normalizedToPlusMinus180Degrees() const;
|
CHeading normalizedToPlusMinus180Degrees() const;
|
||||||
|
|
||||||
|
//! As [0, 359.99] normalized heading
|
||||||
|
CHeading normalizedTo360Degrees() const;
|
||||||
|
|
||||||
//! Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user