mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
Ref T111, different implementation as recommended by MS
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6b4e10f81b
commit
4e45496431
@@ -77,32 +77,28 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAngle::DegMinSecFractionalSec CAngle::asSexagesimalDegMinSec(bool range180Degrees) const
|
CAngle::DegMinSecFractionalSec CAngle::asSexagesimalDegMinSec(bool range180Degrees) const
|
||||||
{
|
{
|
||||||
double v = this->value(CAngleUnit::deg());
|
double dms = this->value(CAngleUnit::sexagesimalDeg());
|
||||||
v = CAngleUnit::deg().roundToEpsilon(v);
|
|
||||||
|
|
||||||
// range -179-180 ?
|
|
||||||
if (range180Degrees)
|
if (range180Degrees)
|
||||||
{
|
{
|
||||||
v = std::fmod(v + 180.0, 360.0);
|
dms = std::fmod(dms + 180.0, 360.0);
|
||||||
v += (v < 0) ? 180.0 : -180.0;
|
dms += (dms < 0) ? 180.0 : -180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DegMinSecFractionalSec values;
|
DegMinSecFractionalSec values;
|
||||||
if (v < 0)
|
if (dms < 0)
|
||||||
{
|
{
|
||||||
values.sign = -1;
|
values.sign = -1;
|
||||||
v *= -1.0;
|
dms *= -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
values.deg = v;
|
values.deg = CMathUtils::trunc(dms);
|
||||||
v -= values.deg;
|
dms = CMathUtils::fract(dms) * 100;
|
||||||
v = v * 100.0 * 0.6;
|
values.min = CMathUtils::trunc(dms);
|
||||||
values.min = v;
|
dms = CMathUtils::fract(dms) * 100;
|
||||||
v -= values.min;
|
values.sec = CMathUtils::trunc(dms);
|
||||||
v = v * 100.0 * 0.6;
|
dms = CMathUtils::fract(dms);
|
||||||
values.sec = v;
|
values.fractionalSec = CMathUtils::round(dms, 6);
|
||||||
v -= values.sec;
|
|
||||||
values.fractionalSec = CMathUtils::round(v, 6);
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user