mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T429, functions for angle, heading and situation
* normalize angle -180/+180 when set on situation * clamp vector function
This commit is contained in:
@@ -109,6 +109,21 @@ namespace BlackMisc
|
||||
return std::tan(this->value(CAngleUnit::rad()));
|
||||
}
|
||||
|
||||
void CAngle::normalizeToPlusMinus180Degrees()
|
||||
{
|
||||
const double v = normalizeDegrees180(this->value(CAngleUnit::deg()));
|
||||
const CAngleUnit u = this->getUnit();
|
||||
*this = CAngle(v, CAngleUnit::deg());
|
||||
this->switchUnit(u);
|
||||
}
|
||||
|
||||
CAngle CAngle::normalizedToPlusMinus180Degrees() const
|
||||
{
|
||||
CAngle copy(*this);
|
||||
copy.normalizeToPlusMinus180Degrees();
|
||||
return copy;
|
||||
}
|
||||
|
||||
double CAngle::normalizeDegrees180(double degrees, int roundDigits)
|
||||
{
|
||||
double d = CMathUtils::normalizeDegrees360(degrees + 180.0) - 180.0;
|
||||
|
||||
@@ -97,6 +97,12 @@ namespace BlackMisc
|
||||
//! Tangent of angle
|
||||
double tan() const;
|
||||
|
||||
//! Normalize to +- 180deg, [-179.99, 180.0]
|
||||
void normalizeToPlusMinus180Degrees();
|
||||
|
||||
//! As [-179.99, 180.0] normalized heading
|
||||
CAngle normalizedToPlusMinus180Degrees() const;
|
||||
|
||||
//! Normalize: -180< degrees ≤180
|
||||
static double normalizeDegrees180(double degrees, int roundDigits = -1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user