Astrodynamics coordinate frame transforms
0
fork

Configure Feed

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

coordinate: expose GAST and use deg_to_rad in tests

Two unused-value warnings in ocaml-coordinate, both cases of
incomplete features rather than dead code:

1. [eq_equinoxes] (the nutation correction that converts GMST to GAST)
was defined in the library but never called from anywhere — the
companion GAST function was never written. Adding:
- [gast_of_unix : float -> float]
- [gast : Ptime.t -> float]
just after [eq_equinoxes] in the implementation, and re-exposing
both near [gmst] in the .mli. GAST is the proper "Earth-rotation
time of day" quantity to use when the observation requires
nutation awareness.

2. [deg_to_rad] in test_coordinate.ml was defined alongside
[rad_to_deg] but only the latter was used. Two test call sites had
[Float.pi /. 2.] where [deg_to_rad 90.] reads cleaner. Migrating
both.

+17 -2
+7
lib/coordinate.ml
··· 269 269 let dpsi, _deps = nutation_dpsi_deps t in 270 270 dpsi *. cos (mean_obliquity t) 271 271 272 + (* Apparent sidereal time: GMST + equation of the equinoxes. *) 273 + let gast_of_unix unix_time = 274 + let t = julian_centuries unix_time in 275 + normalize_angle (gmst_of_unix unix_time +. eq_equinoxes t) 276 + 277 + let gast ptime = gast_of_unix (Ptime.to_float_s ptime) 278 + 272 279 (* Apply precession: MOD → J2000. P^T = Rz(zeta) * Ry(-theta) * Rz(z) *) 273 280 let precess_mod_to_j2000 t v = 274 281 let zeta_a, theta_a, z_a = precession_angles t in
+8
lib/coordinate.mli
··· 41 41 val gmst : Ptime.t -> float 42 42 (** [gmst t] returns Greenwich Mean Sidereal Time in radians. *) 43 43 44 + val gast : Ptime.t -> float 45 + (** [gast t] returns Greenwich Apparent Sidereal Time in radians — GMST 46 + plus the equation of the equinoxes (the nutation-driven correction 47 + that accounts for the wobble of the true equinox relative to the 48 + mean equinox). Use this when you need sidereal time aligned with 49 + the true orientation of Earth's axis rather than the mean 50 + orientation. *) 51 + 44 52 val julian_date_of_unix : float -> float 45 53 (** [julian_date_of_unix t] converts Unix timestamp to Julian date. *) 46 54
+2 -2
test/test_coordinate.ml
··· 116 116 · Y = 0 ECEF Y' = -sin θ · X + cos θ · Y = -1000 *) 117 117 let test_teme_ecef_90deg () = 118 118 let v = Vec3.v 1000. 0. 0. in 119 - let gmst = Float.pi /. 2. in 119 + let gmst = deg_to_rad 90. in 120 120 let ecef = Coordinate.teme_to_ecef ~gmst v in 121 121 check_float "x" 1e-6 0. ecef.x; 122 122 check_float "y" 1e-6 (-1000.) ecef.y; ··· 248 248 let r = Coordinate.earth_radius +. 400. in 249 249 let v = Vec3.v r 0. 0. in 250 250 let g0 = Coordinate.teme_to_geodetic ~gmst:0. v in 251 - let g90 = Coordinate.teme_to_geodetic ~gmst:(Float.pi /. 2.) v in 251 + let g90 = Coordinate.teme_to_geodetic ~gmst:(deg_to_rad 90.) v in 252 252 let dlon = g0.lon -. g90.lon in 253 253 check_float "lon shift 90°" 1. 90. (abs_float dlon) 254 254