Ref T429, functions for angle, heading and situation

* normalize angle -180/+180 when set on situation
* clamp vector function
This commit is contained in:
Klaus Basan
2018-11-09 02:26:07 +01:00
parent 985c06816b
commit 7807a05f2a
8 changed files with 89 additions and 33 deletions

View File

@@ -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;