FOUND Coverage Report


src/
File: distance/output.cpp
Date: 2025-11-20 21:57:26
Lines:
10/10
100.0%
Functions:
1/1
100.0%
Branches:
4/4
100.0%

Line Branch Exec Source
1 #include "distance/output.hpp"
2
3 #include <ctime>
4
5 #include "common/spatial/attitude-utils.hpp"
6 #include "common/time/time.hpp"
7 #include "common/decimal.hpp"
8
9 namespace found {
10
11 5 EarthSphericalVec3 GetEarthCoordinates(Vec3 &celestialVector, decimal gmst) {
12 // Converts epoch time to GMST in degrees, then we convert to radians
13 // We should ensure Euclidean Mod, but both the divisor and dividend
14 // are positive, so we don't need it (GMST > 0 after Jan 1st, 2000).
15 5 decimal GMST = std::fmod(DECIMAL_M_PI * gmst / DECIMAL(180.0), 2 * DECIMAL_M_PI);
16 // Figure out Earth's Rotating Frame and express the position in that frame
17
1/1
✓ Branch 2 taken 5 times.
5 Quaternion toEarthRotatingFrame = SphericalToQuaternion(GMST, 0, 0);
18
1/1
✓ Branch 2 taken 5 times.
5 Vec3 position = toEarthRotatingFrame.Rotate(celestialVector);
19
20 // Figure out the right ascension and declination of the vector
21 5 decimal RA = std::atan2(position.y, position.x); // Huh, the range is [-PI, PI], not [0, 2PI]. That's convenient
22
1/1
✓ Branch 2 taken 5 times.
5 decimal DE = std::asin(position.Normalize().z); // Range is [-PI/2, PI/2]
23
24 // Longitude, Lattitude and Altitude Follow, with conversion
25 // to degrees and range adjustment from RA to longitude
26 5 return {RadToDeg(RA),
27 5 RadToDeg(DE),
28 10 position.Magnitude(),
29
1/1
✓ Branch 2 taken 5 times.
10 gmst};
30 }
31
32 } // namespace found
33