Astrodynamics coordinate frame transforms
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Unified Satellite.v with optional ~propagate

+40 -8
+37
README.md
··· 1 + # coordinate 2 + 3 + Astrodynamics coordinate frame transforms. 4 + 5 + Conversions between standard reference frames used in satellite operations: TEME (SGP4 output), ECEF (Earth-fixed), J2000/EME2000 (inertial), and geodetic (lat/lon/alt). Includes WGS-84 constants and GMST computation. 6 + 7 + ## Installation 8 + 9 + ``` 10 + opam install coordinate 11 + ``` 12 + 13 + ## Usage 14 + 15 + ```ocaml 16 + (* Convert SGP4 TEME output to geodetic coordinates *) 17 + let gmst = Coordinate.gmst_of_unix unix_time in 18 + let ecef = Coordinate.teme_to_ecef ~gmst teme_pos in 19 + let geo = Coordinate.ecef_to_geodetic ecef in 20 + Printf.printf "Lat: %.4f Lon: %.4f Alt: %.1f km\n" geo.lat geo.lon geo.alt 21 + ``` 22 + 23 + ## API Overview 24 + 25 + - **`type vec3`** -- Cartesian position/velocity vector (km or km/s) 26 + - **`type geodetic`** -- `lat` (deg), `lon` (deg), `alt` (km) 27 + - **`earth_radius`**, **`earth_mu`**, **`earth_j2`** -- WGS-84 constants 28 + - **`gmst_of_unix`**, **`gmst`** -- Greenwich Mean Sidereal Time (IAU 1982) 29 + - **`teme_to_ecef`**, **`ecef_to_teme`** -- TEME/ECEF rotation via GMST 30 + - **`j2000_to_ecef`**, **`ecef_to_j2000`** -- J2000/ECEF rotation 31 + - **`ecef_to_geodetic`** -- Bowring's iterative method on WGS-84 ellipsoid 32 + - **`geodetic_to_ecef`** -- Geodetic to ECEF 33 + - **`teme_to_geodetic`** -- TEME to geodetic (convenience) 34 + 35 + ## License 36 + 37 + ISC
+3 -8
test/test_coordinate.ml
··· 227 227 let g = Coordinate.ecef_to_geodetic v in 228 228 (* Approximate — the example uses a different reference ellipsoid *) 229 229 let r = Coordinate.vec3_length v in 230 - let expected_r = 231 - sqrt 232 - ((6524.834 *. 6524.834) +. (6862.875 *. 6862.875) +. (6448.296 *. 6448.296) 233 - ) 234 - in 235 - Alcotest.(check (float 0.1)) "radius" expected_r r; 236 - Alcotest.(check (float 2.0)) "lat ~34" 34. g.lat; 237 - Alcotest.(check (float 200.)) "alt ~5000" 5000. g.alt 230 + Alcotest.(check (float 0.001)) "radius" 11456.572 r; 231 + Alcotest.(check (float 0.5)) "lat" 34.25 g.lat; 232 + Alcotest.(check (float 50.)) "alt" 5078. g.alt 238 233 239 234 (* ================================================================== *) 240 235 (* TEME → Geodetic (full pipeline) *)