MCPcopy Create free account
hub / github.com/comaps/comaps / GetShortestDistance

Function GetShortestDistance

libs/geometry/angles.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18double GetShortestDistance(double rad1, double rad2)
19{
20 double constexpr period = 2.0 * math::pi;
21 rad1 = fmod(rad1, period);
22 rad2 = fmod(rad2, period);
23
24 double res = rad2 - rad1;
25 if (fabs(res) > math::pi)
26 {
27 if (res < 0.0)
28 res = period + res;
29 else
30 res = -period + res;
31 }
32 return res;
33}
34
35double GetMiddleAngle(double a1, double a2)
36{

Callers 6

OnCompassUpdatedMethod · 0.85
UNIT_TESTFunction · 0.85
InterpolateAngleFunction · 0.85
GetRotateDurationMethod · 0.85
AdvanceMethod · 0.85

Calls

no outgoing calls

Tested by 1

UNIT_TESTFunction · 0.68