FOUND Coverage Report


src/
File: distance/output.cpp
Date: 2026-03-24 21:41:51
Lines:
13/13
100.0%
Functions:
2/2
100.0%
Branches:
5/5
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 10 ECEFCoordinates GetEarthCoordinates(Vec3 &celestialVector, decimal gmst) {
12 // Converts GMST from degrees 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 // The fmod ensures the result is in [0, 2π) radians
16 10 decimal GMST = std::fmod(DECIMAL_M_PI * gmst / DECIMAL(180.0), 2 * DECIMAL_M_PI);
17
18 // Convert from celestial (inertial) frame to Earth-Centered, Earth-Fixed (ECEF) frame
19 // Standard ECEF convention requires rotation by -GMST around Z-axis.
20
1/1
✓ Branch 2 taken 10 times.
10 Quaternion toEarthRotatingFrame = SphericalToQuaternion(GMST, 0, 0);
21
1/1
✓ Branch 2 taken 10 times.
10 Vec3 position = toEarthRotatingFrame.Rotate(celestialVector);
22
23 20 return ECEFCoordinates(position);
24 }
25
26 5 EarthSphericalVec3 GetEarthLLACoordinates(Vec3 &celestialVector, decimal gmst) {
27
1/1
✓ Branch 2 taken 5 times.
5 Vec3 position = GetEarthCoordinates(celestialVector, gmst);
28
29 // Figure out the right ascension and declination of the vector
30 5 decimal RA = std::atan2(position.y, position.x); // Huh, the range is [-PI, PI], not [0, 2PI]. That's convenient
31
1/1
✓ Branch 2 taken 5 times.
5 decimal DE = std::asin(position.Normalize().z); // Range is [-PI/2, PI/2]
32
33 // Longitude, Lattitude and Altitude Follow, with conversion
34 // to degrees and range adjustment from RA to longitude
35 5 return {RadToDeg(RA),
36 5 RadToDeg(DE),
37 10 position.Magnitude(),
38
1/1
✓ Branch 2 taken 5 times.
5 gmst};
39 }
40
41 } // namespace found
42