1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/// Python wrapper for EllipsoidalConversionType enum
///
/// Specifies the type of ellipsoidal conversion used in coordinate transformations.
/// Convert osculating orbital elements to Cartesian state.
///
/// Transforms a state vector from osculating Keplerian orbital elements to Cartesian
/// position and velocity coordinates.
///
/// Args:
/// x_oe (numpy.ndarray or list): Osculating orbital elements `[a, e, i, RAAN, omega, M]` where
/// `a` is semi-major axis (meters), `e` is eccentricity (dimensionless), `i` is
/// inclination (radians or degrees), `RAAN` is right ascension of ascending node
/// (radians or degrees), `omega` is argument of periapsis (radians or degrees),
/// and `M` is mean anomaly (radians or degrees).
/// angle_format (AngleFormat): Angle format for angular elements (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Cartesian state `[x, y, z, vx, vy, vz]` where position is in meters
/// and velocity is in meters per second.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Orbital elements for a circular orbit
/// oe = np.array([7000000.0, 0.0, 0.0, 0.0, 0.0, 0.0]) # a, e, i, RAAN, omega, M
/// x_cart = bh.state_koe_to_eci(oe, bh.AngleFormat.RADIANS)
/// print(f"Cartesian state: {x_cart}")
/// ```
/// Convert Cartesian state to osculating orbital elements.
///
/// Transforms a state vector from Cartesian position and velocity coordinates to
/// osculating Keplerian orbital elements.
///
/// Args:
/// x_cart (numpy.ndarray or list): Cartesian state `[x, y, z, vx, vy, vz]` where position
/// is in meters and velocity is in meters per second.
/// angle_format (AngleFormat): Angle format for output angular elements (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Osculating orbital elements `[a, e, i, RAAN, omega, M]` where `a` is
/// semi-major axis (meters), `e` is eccentricity (dimensionless), `i` is inclination
/// (radians or degrees), `RAAN` is right ascension of ascending node (radians or degrees),
/// `omega` is argument of periapsis (radians or degrees), and `M` is mean anomaly
/// (radians or degrees).
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Cartesian state vector
/// x_cart = np.array([7000000.0, 0.0, 0.0, 0.0, 7546.0, 0.0]) # [x, y, z, vx, vy, vz]
/// oe = bh.state_eci_to_koe(x_cart, bh.AngleFormat.RADIANS)
/// print(f"Orbital elements: a={oe[0]:.0f}m, e={oe[1]:.6f}, i={oe[2]:.6f} rad")
/// ```
/// Convert geocentric position to `ECEF` Cartesian coordinates.
///
/// Transforms a position from geocentric spherical coordinates (longitude, latitude, radius)
/// to Earth-Centered Earth-Fixed (`ECEF`) Cartesian coordinates.
///
/// Args:
/// x_geoc (numpy.ndarray or list): Geocentric position `[longitude, latitude, radius]` where
/// longitude is in radians or degrees, latitude is in radians or degrees, and
/// radius is in meters.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: `ECEF` Cartesian position `[x, y, z]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert geocentric coordinates to ECEF
/// lon, lat, r = 0.0, 0.0, 6378137.0 # Equator, prime meridian, Earth's radius
/// x_geoc = np.array([lon, lat, r])
/// x_ecef = bh.position_geocentric_to_ecef(x_geoc, bh.AngleFormat.RADIANS)
/// print(f"ECEF position: {x_ecef}")
/// ```
/// Convert `ECEF` Cartesian position to geocentric coordinates.
///
/// Transforms a position from Earth-Centered Earth-Fixed (`ECEF`) Cartesian coordinates
/// to geocentric spherical coordinates (longitude, latitude, radius).
///
/// Args:
/// x_ecef (numpy.ndarray or list): `ECEF` Cartesian position `[x, y, z]` in meters.
/// angle_format (AngleFormat): Angle format for output angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Geocentric position `[longitude, latitude, radius]` where longitude
/// is in radians or degrees, latitude is in radians or degrees, and radius is in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert ECEF to geocentric coordinates
/// x_ecef = np.array([6378137.0, 0.0, 0.0]) # Point on equator, prime meridian
/// x_geoc = bh.position_ecef_to_geocentric(x_ecef, bh.AngleFormat.DEGREES)
/// print(f"Geocentric: lon={x_geoc[0]:.2f}°, lat={x_geoc[1]:.2f}°, r={x_geoc[2]:.0f}m")
/// ```
/// Convert geodetic position to `ECEF` Cartesian coordinates.
///
/// Transforms a position from geodetic coordinates (longitude, latitude, altitude) using
/// the `WGS84` ellipsoid model to Earth-Centered Earth-Fixed (`ECEF`) Cartesian coordinates.
///
/// Args:
/// x_geod (numpy.ndarray or list): Geodetic position `[longitude, latitude, altitude]` where
/// longitude is in radians or degrees, latitude is in radians or degrees, and
/// altitude is in meters above the `WGS84` ellipsoid.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: `ECEF` Cartesian position `[x, y, z]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert geodetic coordinates (GPS-like) to ECEF
/// lon, lat, alt = -105.0, 40.0, 1655.0 # Boulder, CO (degrees, meters)
/// x_geod = np.array([lon, lat, alt])
/// x_ecef = bh.position_geodetic_to_ecef(x_geod, bh.AngleFormat.DEGREES)
/// print(f"ECEF position: {x_ecef}")
/// ```
/// Convert `ECEF` Cartesian position to geodetic coordinates.
///
/// Transforms a position from Earth-Centered Earth-Fixed (`ECEF`) Cartesian coordinates
/// to geodetic coordinates (longitude, latitude, altitude) using the `WGS84` ellipsoid model.
///
/// Args:
/// x_ecef (numpy.ndarray or list): `ECEF` Cartesian position `[x, y, z]` in meters.
/// angle_format (AngleFormat): Angle format for output angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Geodetic position `[longitude, latitude, altitude]` where longitude
/// is in radians or degrees, latitude is in radians or degrees, and altitude
/// is in meters above the `WGS84` ellipsoid.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert ECEF to geodetic coordinates (GPS-like)
/// x_ecef = np.array([-1275936.0, -4797210.0, 4020109.0]) # Example location
/// x_geod = bh.position_ecef_to_geodetic(x_ecef, bh.AngleFormat.DEGREES)
/// print(f"Geodetic: lon={x_geod[0]:.4f}°, lat={x_geod[1]:.4f}°, alt={x_geod[2]:.0f}m")
/// ```
/// Compute rotation matrix from ellipsoidal coordinates to East-North-Up (`ENZ`) frame.
///
/// Calculates the rotation matrix that transforms vectors from an ellipsoidal coordinate
/// frame (geocentric or geodetic) to the local East-North-Up (`ENZ`) topocentric frame at
/// the specified location.
///
/// Args:
/// x_ellipsoid (numpy.ndarray or list): Ellipsoidal position `[latitude, longitude, altitude/radius]`
/// where latitude is in radians or degrees, longitude is in radians or degrees.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: 3x3 rotation matrix from ellipsoidal frame to `ENZ` frame.
/// Compute rotation matrix from East-North-Up (`ENZ`) frame to ellipsoidal coordinates.
///
/// Calculates the rotation matrix that transforms vectors from the local East-North-Up
/// (`ENZ`) topocentric frame to an ellipsoidal coordinate frame (geocentric or geodetic)
/// at the specified location.
///
/// Args:
/// x_ellipsoid (numpy.ndarray or list): Ellipsoidal position `[latitude, longitude, altitude/radius]`
/// where latitude is in radians or degrees, longitude is in radians or degrees.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: 3x3 rotation matrix from `ENZ` frame to ellipsoidal frame.
/// Convert relative position from `ECEF` to East-North-Up (`ENZ`) frame.
///
/// Transforms a relative position vector from Earth-Centered Earth-Fixed (`ECEF`) coordinates
/// to the local East-North-Up (`ENZ`) topocentric frame at the specified location.
///
/// Args:
/// location_ecef (numpy.ndarray or list): Reference location in `ECEF` coordinates `[x, y, z]` in meters.
/// r_ecef (numpy.ndarray or list): Position vector in `ECEF` coordinates `[x, y, z]` in meters.
/// conversion_type (EllipsoidalConversionType): Type of ellipsoidal conversion (`GEOCENTRIC` or `GEODETIC`).
///
/// Returns:
/// numpy.ndarray: Relative position in `ENZ` frame `[east, north, up]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Ground station and satellite positions
/// station_ecef = np.array([4000000.0, 3000000.0, 4000000.0])
/// sat_ecef = np.array([4100000.0, 3100000.0, 4100000.0])
/// enz = bh.relative_position_ecef_to_enz(station_ecef, sat_ecef, bh.EllipsoidalConversionType.GEODETIC)
/// print(f"ENZ: East={enz[0]/1000:.1f}km, North={enz[1]/1000:.1f}km, Up={enz[2]/1000:.1f}km")
/// ```
/// Convert relative position from East-North-Up (`ENZ`) frame to `ECEF`.
///
/// Transforms a relative position vector from the local East-North-Up (`ENZ`) topocentric
/// frame to Earth-Centered Earth-Fixed (`ECEF`) coordinates at the specified location.
///
/// Args:
/// location_ecef (numpy.ndarray or list): Reference location in `ECEF` coordinates `[x, y, z]` in meters.
/// r_enz (numpy.ndarray or list): Relative position in `ENZ` frame `[east, north, up]` in meters.
/// conversion_type (EllipsoidalConversionType): Type of ellipsoidal conversion (`GEOCENTRIC` or `GEODETIC`).
///
/// Returns:
/// numpy.ndarray: Position vector in `ECEF` coordinates `[x, y, z]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert ENZ offset back to ECEF
/// station_ecef = np.array([4000000.0, 3000000.0, 4000000.0])
/// enz_offset = np.array([50000.0, 30000.0, 100000.0]) # 50km east, 30km north, 100km up
/// target_ecef = bh.relative_position_enz_to_ecef(station_ecef, enz_offset, bh.EllipsoidalConversionType.GEODETIC)
/// print(f"Target ECEF: {target_ecef}")
/// ```
/// Compute rotation matrix from ellipsoidal coordinates to South-East-Zenith (`SEZ`) frame.
///
/// Calculates the rotation matrix that transforms vectors from an ellipsoidal coordinate
/// frame (geocentric or geodetic) to the local South-East-Zenith (`SEZ`) topocentric frame
/// at the specified location.
///
/// Args:
/// x_ellipsoid (numpy.ndarray or list): Ellipsoidal position `[latitude, longitude, altitude/radius]`
/// where latitude is in radians or degrees, longitude is in radians or degrees.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: 3x3 rotation matrix from ellipsoidal frame to `SEZ` frame.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Get rotation matrix for ground station in SEZ frame
/// lat, lon, alt = 0.7, -1.5, 100.0 # radians, meters
/// x_geod = np.array([lat, lon, alt])
/// R_sez = bh.rotation_ellipsoid_to_sez(x_geod, bh.AngleFormat.RADIANS)
/// print(f"Rotation matrix shape: {R_sez.shape}")
/// ```
/// Compute rotation matrix from South-East-Zenith (`SEZ`) frame to ellipsoidal coordinates.
///
/// Calculates the rotation matrix that transforms vectors from the local South-East-Zenith
/// (`SEZ`) topocentric frame to an ellipsoidal coordinate frame (geocentric or geodetic)
/// at the specified location.
///
/// Args:
/// x_ellipsoid (numpy.ndarray or list): Ellipsoidal position `[latitude, longitude, altitude/radius]`
/// where latitude is in radians or degrees, longitude is in radians or degrees.
/// angle_format (AngleFormat): Angle format for input angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: 3x3 rotation matrix from `SEZ` frame to ellipsoidal frame.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Get inverse rotation matrix from SEZ to ellipsoidal
/// lat, lon, alt = 0.7, -1.5, 100.0 # radians, meters
/// x_geod = np.array([lat, lon, alt])
/// R_ellipsoid = bh.rotation_sez_to_ellipsoid(x_geod, bh.AngleFormat.RADIANS)
/// print(f"Rotation matrix shape: {R_ellipsoid.shape}")
/// ```
/// Convert relative position from `ECEF` to South-East-Zenith (`SEZ`) frame.
///
/// Transforms a relative position vector from Earth-Centered Earth-Fixed (`ECEF`) coordinates
/// to the local South-East-Zenith (`SEZ`) topocentric frame at the specified location.
///
/// Args:
/// location_ecef (numpy.ndarray or list): Reference location in `ECEF` coordinates `[x, y, z]` in meters.
/// r_ecef (numpy.ndarray or list): Position vector in `ECEF` coordinates `[x, y, z]` in meters.
/// conversion_type (EllipsoidalConversionType): Type of ellipsoidal conversion (`GEOCENTRIC` or `GEODETIC`).
///
/// Returns:
/// numpy.ndarray: Relative position in `SEZ` frame `[south, east, zenith]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Ground station and satellite positions
/// station_ecef = np.array([4000000.0, 3000000.0, 4000000.0])
/// sat_ecef = np.array([4100000.0, 3100000.0, 4100000.0])
/// sez = bh.relative_position_ecef_to_sez(station_ecef, sat_ecef, bh.EllipsoidalConversionType.GEODETIC)
/// print(f"SEZ: South={sez[0]/1000:.1f}km, East={sez[1]/1000:.1f}km, Zenith={sez[2]/1000:.1f}km")
/// ```
/// Convert relative position from South-East-Zenith (`SEZ`) frame to `ECEF`.
///
/// Transforms a relative position vector from the local South-East-Zenith (`SEZ`) topocentric
/// frame to Earth-Centered Earth-Fixed (`ECEF`) coordinates at the specified location.
///
/// Args:
/// location_ecef (numpy.ndarray or list): Reference location in `ECEF` coordinates `[x, y, z]` in meters.
/// x_sez (numpy.ndarray or list): Relative position in `SEZ` frame `[south, east, zenith]` in meters.
/// conversion_type (EllipsoidalConversionType): Type of ellipsoidal conversion (`GEOCENTRIC` or `GEODETIC`).
///
/// Returns:
/// numpy.ndarray: Position vector in `ECEF` coordinates `[x, y, z]` in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert SEZ offset back to ECEF
/// station_ecef = np.array([4000000.0, 3000000.0, 4000000.0])
/// sez_offset = np.array([30000.0, 50000.0, 100000.0]) # 30km south, 50km east, 100km up
/// target_ecef = bh.relative_position_sez_to_ecef(station_ecef, sez_offset, bh.EllipsoidalConversionType.GEODETIC)
/// print(f"Target ECEF: {target_ecef}")
/// ```
/// Convert position from East-North-Up (`ENZ`) frame to azimuth-elevation-range.
///
/// Transforms a position from the local East-North-Up (`ENZ`) topocentric frame to
/// azimuth-elevation-range spherical coordinates.
///
/// Args:
/// x_enz (numpy.ndarray or list): Position in `ENZ` frame `[east, north, up]` in meters.
/// angle_format (AngleFormat): Angle format for output angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Azimuth-elevation-range `[azimuth, elevation, range]` where azimuth
/// and elevation are in radians or degrees, and range is in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert ENZ to azimuth-elevation for satellite tracking
/// enz = np.array([50000.0, 100000.0, 200000.0]) # East, North, Up (meters)
/// azel = bh.position_enz_to_azel(enz, bh.AngleFormat.DEGREES)
/// print(f"Az={azel[0]:.1f}°, El={azel[1]:.1f}°, Range={azel[2]/1000:.1f}km")
/// ```
/// Convert position from South-East-Zenith (`SEZ`) frame to azimuth-elevation-range.
///
/// Transforms a position from the local South-East-Zenith (`SEZ`) topocentric frame to
/// azimuth-elevation-range spherical coordinates.
///
/// Args:
/// x_sez (numpy.ndarray or list): Position in `SEZ` frame `[south, east, zenith]` in meters.
/// angle_format (AngleFormat): Angle format for output angular coordinates (`RADIANS` or `DEGREES`).
///
/// Returns:
/// numpy.ndarray: Azimuth-elevation-range `[azimuth, elevation, range]` where azimuth
/// and elevation are in radians or degrees, and range is in meters.
///
/// Example:
/// ```python
/// import brahe as bh
/// import numpy as np
///
/// # Convert SEZ to azimuth-elevation for satellite tracking
/// sez = np.array([30000.0, 50000.0, 100000.0]) # South, East, Zenith (meters)
/// azel = bh.position_sez_to_azel(sez, bh.AngleFormat.DEGREES)
/// print(f"Az={azel[0]:.1f}°, El={azel[1]:.1f}°, Range={azel[2]/1000:.1f}km")
/// ```