Astrodynamics coordinate frame transforms
0
fork

Configure Feed

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

Replace Printf/Format with Fmt, rename test_cara

Style: Fmt.pr/str/pf across collision, spacedata, stix, ocm.
Rename test_cara → test_collision_properties.

+18 -18
+1 -1
fuzz/dune
··· 1 1 (executable 2 2 (name fuzz) 3 3 (modules fuzz fuzz_coordinate) 4 - (libraries coordinate alcobar)) 4 + (libraries coordinate vec3 alcobar)) 5 5 6 6 (rule 7 7 (alias runtest)
+1 -1
fuzz/fuzz_coordinate.ml
··· 18 18 Float.is_finite x && Float.is_finite y && Float.is_finite z 19 19 && Float.is_finite gmst 20 20 then begin 21 - let v = Coordinate.vec3 x y z in 21 + let v = Vec3.v x y z in 22 22 let ecef = Coordinate.teme_to_ecef ~gmst v in 23 23 let v' = Coordinate.ecef_to_teme ~gmst ecef in 24 24 guard (Float.is_finite v'.x);
+1 -1
test/dune
··· 1 1 (test 2 2 (name test) 3 - (libraries coordinate alcotest ptime)) 3 + (libraries coordinate vec3 alcotest ptime))
+15 -15
test/test_coordinate.ml
··· 106 106 107 107 (** At GMST=0, TEME and ECEF are aligned. *) 108 108 let test_teme_ecef_zero () = 109 - let v = Coordinate.vec3 1000. 2000. 3000. in 109 + let v = Vec3.v 1000. 2000. 3000. in 110 110 let ecef = Coordinate.teme_to_ecef ~gmst:0. v in 111 111 check_float "x" 1e-6 1000. ecef.x; 112 112 check_float "y" 1e-6 2000. ecef.y; ··· 115 115 (** At GMST=π/2: Rz(π/2)*(1000,0,0) = (0, -1000, 0). ECEF X' = cos θ · X + sin θ 116 116 · Y = 0 ECEF Y' = -sin θ · X + cos θ · Y = -1000 *) 117 117 let test_teme_ecef_90deg () = 118 - let v = Coordinate.vec3 1000. 0. 0. in 118 + let v = Vec3.v 1000. 0. 0. in 119 119 let gmst = Float.pi /. 2. in 120 120 let ecef = Coordinate.teme_to_ecef ~gmst v in 121 121 check_float "x" 1e-6 0. ecef.x; ··· 124 124 125 125 (** Round-trip: TEME → ECEF → TEME should be identity. *) 126 126 let test_teme_ecef_roundtrip () = 127 - let v = Coordinate.vec3 6524.834 6862.875 6448.296 in 127 + let v = Vec3.v 6524.834 6862.875 6448.296 in 128 128 let gmst = 1.7 in 129 129 let ecef = Coordinate.teme_to_ecef ~gmst v in 130 130 let v' = Coordinate.ecef_to_teme ~gmst ecef in ··· 134 134 135 135 (** Rotation preserves vector length. *) 136 136 let test_rotation_preserves_length () = 137 - let v = Coordinate.vec3 7000. 1000. 3000. in 138 - let r0 = Coordinate.vec3_length v in 137 + let v = Vec3.v 7000. 1000. 3000. in 138 + let r0 = Vec3.length v in 139 139 let ecef = Coordinate.teme_to_ecef ~gmst:2.345 v in 140 - let r1 = Coordinate.vec3_length ecef in 140 + let r1 = Vec3.length ecef in 141 141 check_float "length preserved" 1e-6 r0 r1 142 142 143 143 (* ================================================================== *) ··· 147 147 (** Point on equator at prime meridian: lat=0, lon=0, alt=0. ECEF = (a, 0, 0) 148 148 where a = earth_radius. *) 149 149 let test_geodetic_equator_pm () = 150 - let v = Coordinate.vec3 Coordinate.earth_radius 0. 0. in 150 + let v = Vec3.v Coordinate.earth_radius 0. 0. in 151 151 let g = Coordinate.ecef_to_geodetic v in 152 152 check_float "lat" 0.01 0. g.lat; 153 153 check_float "lon" 0.01 0. g.lon; ··· 157 157 a*(1-f). *) 158 158 let test_geodetic_north_pole () = 159 159 let b = Coordinate.earth_radius *. (1. -. Coordinate.earth_flattening) in 160 - let v = Coordinate.vec3 0. 0. b in 160 + let v = Vec3.v 0. 0. b in 161 161 let g = Coordinate.ecef_to_geodetic v in 162 162 check_float "north pole lat" 0.01 90. g.lat; 163 163 check_float "north pole alt" 1. 0. g.alt 164 164 165 165 (** Point at lon=90°E on equator: ECEF = (0, a, 0). *) 166 166 let test_geodetic_lon90 () = 167 - let v = Coordinate.vec3 0. Coordinate.earth_radius 0. in 167 + let v = Vec3.v 0. Coordinate.earth_radius 0. in 168 168 let g = Coordinate.ecef_to_geodetic v in 169 169 check_float "lat" 0.01 0. g.lat; 170 170 check_float "lon" 0.01 90. g.lon ··· 205 205 let test_geodetic_iss_altitude () = 206 206 (* ISS at ~408 km, circular orbit, position along X axis *) 207 207 let r = Coordinate.earth_radius +. 408. in 208 - let v = Coordinate.vec3 r 0. 0. in 208 + let v = Vec3.v r 0. 0. in 209 209 let g = Coordinate.ecef_to_geodetic v in 210 210 check_float "ISS alt" 5. 408. g.alt; 211 211 check_float "ISS lat" 0.1 0. g.lat ··· 214 214 let test_geodetic_geo_altitude () = 215 215 let r = 42164.0 in 216 216 (* GEO radius *) 217 - let v = Coordinate.vec3 r 0. 0. in 217 + let v = Vec3.v r 0. 0. in 218 218 let g = Coordinate.ecef_to_geodetic v in 219 219 let expected_alt = r -. Coordinate.earth_radius in 220 220 check_float "GEO alt" 5. expected_alt g.alt ··· 223 223 6862.875, 6448.296) km Expected: lat ≈ 34.35°, lon ≈ 46.45°, alt ≈ 5085 km. 224 224 *) 225 225 let test_vallado_3_3 () = 226 - let v = Coordinate.vec3 6524.834 6862.875 6448.296 in 226 + let v = Vec3.v 6524.834 6862.875 6448.296 in 227 227 let g = Coordinate.ecef_to_geodetic v in 228 228 (* Approximate — the example uses a different reference ellipsoid *) 229 - let r = Coordinate.vec3_length v in 229 + let r = Vec3.length v in 230 230 Alcotest.(check (float 0.001)) "radius" 11456.572 r; 231 231 Alcotest.(check (float 0.5)) "lat" 34.25 g.lat; 232 232 Alcotest.(check (float 50.)) "alt" 5078. g.alt ··· 238 238 (** TEME position at equator, GMST=0, should give lon≈0. *) 239 239 let test_teme_geodetic_equator () = 240 240 let r = Coordinate.earth_radius +. 400. in 241 - let v = Coordinate.vec3 r 0. 0. in 241 + let v = Vec3.v r 0. 0. in 242 242 let g = Coordinate.teme_to_geodetic ~gmst:0. v in 243 243 check_float "equator lat" 0.1 0. g.lat; 244 244 check_float "equator lon" 0.1 0. g.lon ··· 246 246 (** TEME position at equator with GMST=π/2: lon should shift by -90°. *) 247 247 let test_teme_geodetic_gmst_shift () = 248 248 let r = Coordinate.earth_radius +. 400. in 249 - let v = Coordinate.vec3 r 0. 0. in 249 + let v = Vec3.v r 0. 0. in 250 250 let g0 = Coordinate.teme_to_geodetic ~gmst:0. v in 251 251 let g90 = Coordinate.teme_to_geodetic ~gmst:(Float.pi /. 2.) v in 252 252 let dlon = g0.lon -. g90.lon in