dnwrnr / sgp4

Simplified perturbations models
Apache License 2.0
134 stars 47 forks source link

Accuracy of longitude returned from ToGeodetic() method in Eci class #20

Closed JonathanBMcDonald closed 4 years ago

JonathanBMcDonald commented 4 years ago

I have questions whether the longitude returned fro the ToGeodetic() method in Eci.cc https://github.com/dnwrnr/sgp4/blob/master/libsgp4/Eci.cc

How to recreate what I see:

  1. Edit sattrack.cc on line#51 here (https://github.com/dnwrnr/sgp4/blob/master/sattrack/sattrack.cc#L51) to return the eci coordinates: std::cout << dt << " " << topo << " " << eci.Position().ToString() << " " << geo << std::endl;
  2. Build and execute sattrack. Output is here Norad Number: 35683 Int. Designator: 09041C Epoch: 2012-10-15 05:33:29.214432 UTC Orbit Number: 17229 Mean Motion Dt2: 0.00000484 Mean Motion Ddt6: 0.00000000 Eccentricity: 0.00014990 BStar: 0.00008922 Inclination: 98.02210000 Right Ascending Node: 185.36820000 Argument Perigee: 100.52950000 Mean Anomaly: 259.60880000 Mean Motion: 14.69819587

2012-10-15 05:33:29.214432 UTC Az: 99.301, El: -37.989, Rng: 8856.505, Rng Rt: -4.873 X: -7012.087, Y: -658.897, Z: 0.099, W: 0.000 Lat: 0.001, Lon: 77.841, Alt: 664.840 2012-10-15 05:43:29.214432 UTC Az: 78.676, El: -19.021, Rng: 5728.159, Rng Rt: -5.236 X: -5668.127, Y: 57.323, Z: 4169.584, W: 0.000 Lat: 36.504, Lon: 69.387, Alt: 666.182 2012-10-15 05:53:29.214432 UTC Az: 28.368, El: -3.587, Rng: 3434.215, Rng Rt: -1.074 X: -2071.246, Y: 750.812, Z: 6677.885, W: 0.000 Lat: 71.845, Lon: 47.534, Alt: 673.081 2012-10-15 06:03:29.214432 UTC Az: 327.144, El: -14.261, Rng: 4968.433, Rng Rt: 4.912 X: 2348.083, Y: 1146.299, Z: 6528.632, W: 0.000 Lat: 68.307, Lon: -89.026, Alt: 672.415 2012-10-15 06:13:29.214432 UTC Az: 303.243, El: -33.403, Rng: 8134.569, Rng Rt: 5.183 X: 5834.855, Y: 1086.675, Z: 3780.864, W: 0.000 Lat: 32.656, Lon: -107.004, Alt: 665.196 2012-10-15 06:23:29.214432 UTC Az: 287.911, El: -52.090, Rng: 10886.768, Rng Rt: 3.840 X: 7001.971, Y: 595.085, Z: -473.556, W: 0.000 Lat: -3.879, Lon: -115.203, Alt: 665.114 2012-10-15 06:33:29.214432 UTC Az: 264.193, El: -69.110, Rng: 12616.597, Rng Rt: 1.855 X: 5387.689, Y: -133.000, Z: -4540.162, W: 0.000 Lat: -40.283, Lon: -123.982, Alt: 677.604 2012-10-15 06:43:29.214432 UTC Az: 196.577, El: -76.316, Rng: 13060.761, Rng Rt: -0.393 X: 1640.566, Y: -808.687, Z: -6806.605, W: 0.000 Lat: -75.046, Lon: -151.315, Alt: 689.886 2012-10-15 06:53:29.214432 UTC Az: 147.464, El: -63.705, Rng: 12151.168, Rng Rt: -2.611 X: -2754.019, Y: -1165.544, Z: -6382.130, W: 0.000 Lat: -65.027, Lon: 75.357, Alt: 687.441 2012-10-15 07:03:29.214432 UTC Az: 130.343, El: -45.590, Rng: 9989.590, Rng Rt: -4.517 X: -6061.032, Y: -1062.447, Z: -3433.124, W: 0.000 Lat: -29.306, Lon: 59.854, Alt: 673.322

  1. At t == 0, The ECI coordinates and ECEF are aligned and require no rotation. So we plug the ECI coordinates in this webpage here: https://www.oc.nps.edu/oc2902w/coord/llhxyz.htm and arrive at LLA of

Latitude,Longitude, Height (ellipsoidal) from ECEF

Latitude : 0.00081 deg N Longitude : 185.36809 deg E Height : 664838.9 m

Lat and Alt check out but longitude doesn't

Simular output can be found here: http://www.sysense.com/products/ecef_lla_converter/index.html

I believe the root cause it the may be related to the AcTan function call in Eci.cc. Here I attempted a comparison with atan2 and got very different results.

CoordGeodetic Eci::ToGeodetic() const { const double theta = Util::AcTan(m_position.y, m_position.x); const double thet2a = std::atan2(m_position.y, m_position.x); std::cout << "DEBUG " << theta << " " << thet2a << std::endl;

DEBUG 3.23528 -3.0479

This was as far as I was able to go in debugging things.

JonathanBMcDonald commented 4 years ago

Here I found an example of someone using your method of converting between cartesian coord and LLA: https://stackoverflow.com/questions/18253546/ecef-to-lla-lat-lon-alt-in-java

They used an off-the-shelf standard version of atan2, not withstanding the fact that post at the URL is java and this project is C++, if the post is to be trusted, one doesn't seem to need an arctan method that does special quadrant handling.

JonathanBMcDonald commented 4 years ago

I am withdrawing this issue. I had some misunderstandings about the Eci class. I would rename it to Teme to reflect that special handling is necessary to get a longitude out of the value.