mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Angle, added 360deg functions + formatting
This commit is contained in:
committed by
Mat Sutcliffe
parent
a8c586e174
commit
d713e8a264
@@ -117,6 +117,14 @@ namespace BlackMisc
|
|||||||
this->switchUnit(u);
|
this->switchUnit(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAngle::normalizeTo360Degrees()
|
||||||
|
{
|
||||||
|
const double v = normalizeDegrees360(this->value(CAngleUnit::deg()));
|
||||||
|
const CAngleUnit u = this->getUnit();
|
||||||
|
*this = CAngle(v, CAngleUnit::deg());
|
||||||
|
this->switchUnit(u);
|
||||||
|
}
|
||||||
|
|
||||||
CAngle CAngle::normalizedToPlusMinus180Degrees() const
|
CAngle CAngle::normalizedToPlusMinus180Degrees() const
|
||||||
{
|
{
|
||||||
CAngle copy(*this);
|
CAngle copy(*this);
|
||||||
@@ -124,6 +132,13 @@ namespace BlackMisc
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAngle CAngle::normalizedTo360Degrees() const
|
||||||
|
{
|
||||||
|
CAngle copy(*this);
|
||||||
|
copy.normalizeTo360Degrees();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
double CAngle::normalizeDegrees180(double degrees, int roundDigits)
|
double CAngle::normalizeDegrees180(double degrees, int roundDigits)
|
||||||
{
|
{
|
||||||
double d = CMathUtils::normalizeDegrees360(degrees + 180.0) - 180.0;
|
double d = CMathUtils::normalizeDegrees360(degrees + 180.0) - 180.0;
|
||||||
|
|||||||
@@ -100,9 +100,15 @@ namespace BlackMisc
|
|||||||
//! 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
|
//! Normalize to 0-360, [0, 359,99]
|
||||||
|
void normalizeTo360Degrees();
|
||||||
|
|
||||||
|
//! As [-179.99, 180.0] normalized angle
|
||||||
CAngle normalizedToPlusMinus180Degrees() const;
|
CAngle normalizedToPlusMinus180Degrees() const;
|
||||||
|
|
||||||
|
//! As [0, 359.99] normalized angle
|
||||||
|
CAngle normalizedTo360Degrees() const;
|
||||||
|
|
||||||
//! Normalize: -180< degrees ≤180
|
//! Normalize: -180< degrees ≤180
|
||||||
static double normalizeDegrees180(double degrees, int roundDigits = -1);
|
static double normalizeDegrees180(double degrees, int roundDigits = -1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user