Astrodynamics coordinate frame transforms
0
fork

Configure Feed

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

Deduplicate math: remove pi/twopi aliases, add Coordinate.deg_to_rad

- Remove `let pi = Float.pi` aliases (collision, geometry, sphere,
spacedata) — use Float.pi directly
- Remove `let twopi` aliases (coordinate, kepler/analytic) — inline
- Add Coordinate.deg_to_rad and rad_to_deg, replace inline conversions
in coordinate, heatmap, geometry
- mu already exported as Coordinate.earth_mu and Propagate.mu

+15 -7
+9 -7
lib/coordinate.ml
··· 14 14 let earth_mu = 398600.4418 15 15 let earth_j2 = 0.00108263 16 16 let earth_rotation_rate = 7.2921151467e-5 17 - let twopi = 2. *. Float.pi 18 17 19 18 (* ── Utility ───────────────────────────────────────────────────────── *) 19 + 20 + let deg_to_rad d = d *. Float.pi /. 180. 21 + let rad_to_deg r = r *. 180. /. Float.pi 20 22 21 23 let normalize_angle a = 22 - let a = Float.rem a twopi in 23 - if a < 0. then a +. twopi else a 24 + let a = Float.rem a (2. *. Float.pi) in 25 + if a < 0. then a +. (2. *. Float.pi) else a 24 26 25 27 (* ── Time ──────────────────────────────────────────────────────────── *) 26 28 ··· 39 41 +. (0.093104 *. t *. t) 40 42 -. (6.2e-6 *. t *. t *. t) 41 43 in 42 - normalize_angle (gmst_sec *. twopi /. 86400.) 44 + normalize_angle (gmst_sec *. (2. *. Float.pi) /. 86400.) 43 45 44 46 let gmst ptime = gmst_of_unix (Ptime.to_float_s ptime) 45 47 ··· 74 76 if abs_float (cos !lat_rad) > 1e-10 then (p /. cos !lat_rad) -. n 75 77 else (abs_float v.z /. sin_lat) -. (n *. (1. -. e2)) 76 78 in 77 - { lat = !lat_rad *. 180. /. Float.pi; lon = lon_rad *. 180. /. Float.pi; alt } 79 + { lat = rad_to_deg !lat_rad; lon = rad_to_deg lon_rad; alt } 78 80 79 81 let geodetic_to_ecef g = 80 82 let a = earth_radius in 81 83 let f = earth_flattening in 82 84 let e2 = (2. *. f) -. (f *. f) in 83 - let lat_rad = g.lat *. Float.pi /. 180. in 84 - let lon_rad = g.lon *. Float.pi /. 180. in 85 + let lat_rad = deg_to_rad g.lat in 86 + let lon_rad = deg_to_rad g.lon in 85 87 let sin_lat = sin lat_rad in 86 88 let cos_lat = cos lat_rad in 87 89 let n = a /. sqrt (1. -. (e2 *. sin_lat *. sin_lat)) in
+6
lib/coordinate.mli
··· 49 49 50 50 (** {1 Utility} *) 51 51 52 + val deg_to_rad : float -> float 53 + (** Convert degrees to radians. *) 54 + 55 + val rad_to_deg : float -> float 56 + (** Convert radians to degrees. *) 57 + 52 58 val normalize_angle : float -> float 53 59 54 60 (** {1 Pretty-printing} *)