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

@@ -223,17 +223,23 @@ namespace BlackMisc
v[0] >= -l && v[1] >= -l && v[2] >= -l;
}
int CCoordinateGeodetic::clampVector()
{
int c = 0;
// *INDENT-OFF*
if (m_x < -1.0) { m_x = -1.0; c++; } else if (m_x > 1.0) { m_x = 1.0; c++; }
if (m_y < -1.0) { m_y = -1.0; c++; } else if (m_y > 1.0) { m_y = 1.0; c++; }
if (m_z < -1.0) { m_z = -1.0; c++; } else if (m_z > 1.0) { m_z = 1.0; c++; }
// *INDENT-ON*
return c;
}
CVariant CCoordinateGeodetic::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
if (ICoordinateGeodetic::canHandleIndex(index))
{
return ICoordinateGeodetic::propertyByIndex(index);
}
else
{
return CValueObject::propertyByIndex(index);
}
return (ICoordinateGeodetic::canHandleIndex(index)) ?
ICoordinateGeodetic::propertyByIndex(index) :
CValueObject::propertyByIndex(index);
}
void CCoordinateGeodetic::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
@@ -255,14 +261,9 @@ namespace BlackMisc
int CCoordinateGeodetic::comparePropertyByIndex(const CPropertyIndex &index, const CCoordinateGeodetic &compareValue) const
{
if (ICoordinateGeodetic::canHandleIndex(index))
{
return ICoordinateGeodetic::comparePropertyByIndex(index, compareValue);
}
else
{
return CValueObject::comparePropertyByIndex(index, compareValue);
}
return ICoordinateGeodetic::canHandleIndex(index) ?
ICoordinateGeodetic::comparePropertyByIndex(index, compareValue) :
CValueObject::comparePropertyByIndex(index, compareValue);
}
CCoordinateGeodetic::CCoordinateGeodetic(const std::array<double, 3> &normalVector)