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
//! # Constants and type definitions for Outfit
//!
//! This module centralizes the **physical constants**, **conversion factors**, and **common type
//! definitions** used throughout the `Outfit` library. It also defines key data structures for
//! organizing observations and trajectories.
//!
//! ## Overview
//!
//! - Astronomical and geophysical constants
//! - Unit conversions (degrees ↔ radians, days ↔ seconds, AU ↔ km)
//! - Core type aliases used across the crate
//! - Identifiers for solar system bodies
//! - Container types for storing observations and trajectories
//!
//! These definitions are used by all main modules, including orbit determination, observers,
//! and ephemerides.
// -------------------------------------------------------------------------------------------------
// Physical constants and unit conversions
// -------------------------------------------------------------------------------------------------
use HashMap;
use RandomState;
use ;
use TrajId;
use crate::;
/// 2π, useful for trigonometric conversions
pub const DPI: f64 = 2. * PI;
/// Number of seconds in a Julian day
pub const SECONDS_PER_DAY: f64 = 86_400.0;
/// Astronomical Unit in kilometers (IAU 2012)
pub const AU: f64 = 149_597_870.7;
/// Numerical epsilon used for floating-point comparisons
pub const EPS: f64 = 1e-6;
/// MJD epoch of J2000.0 (2000-01-01 12:00:00 TT)
pub const T2000: f64 = 51544.5;
/// Conversion factor between Julian Date and Modified Julian Date
pub const JDTOMJD: f64 = 2400000.5;
/// Degrees → radians
pub const RADEG: f64 = PI / 180.0;
/// Arcseconds → radians
pub const RADSEC: f64 = PI / 648000.0;
/// Radians → arcseconds
pub const RAD2ARC: f64 = 648000.0 / PI;
/// Hours → radians
pub const RADH: f64 = DPI / 24.0;
/// Earth equatorial radius in meters (GRS1980/WGS84)
pub const EARTH_MAJOR_AXIS: f64 = 6_378_137.0;
/// Earth polar radius in meters (GRS1980/WGS84)
pub const EARTH_MINOR_AXIS: f64 = 6_356_752.3;
/// Earth radius expressed in astronomical units
pub const ERAU: f64 = / AU;
/// Gaussian gravitational constant k (used in classical orbit dynamics)
pub const GAUSS_GRAV: f64 = 0.01720209895;
/// k², often used in Kepler’s third law
pub const GAUSS_GRAV_SQUARED: f64 = GAUSS_GRAV * GAUSS_GRAV;
/// Speed of light in km/s
pub const VLIGHT: f64 = 2.99792458e5;
/// Speed of light in astronomical units per day
pub const VLIGHT_AU: f64 = VLIGHT / AU * SECONDS_PER_DAY;
// Angular velocity of Earth rotation (rad/day) on the z-axis.
pub const EARTH_ROTATION: = new;
// Hard coded rotation matrices for coordinate transformations between mean equatorial J2000 and mean ecliptic J2000 frames.
// Can be computed using the rotpn function in the ref_system module
/// Rotation matrix from mean equatorial J2000 to mean ecliptic J2000.
///
/// Rotation of $-\varepsilon$ around the X-axis, where $\varepsilon$ is the
/// obliquity of the ecliptic at J2000.
///
/// Equivalent to `rotpn(RefSystem::Equm(RefEpoch::J2000), RefSystem::Eclm(RefEpoch::J2000))`.
pub const ROT_EQUMJ2000_TO_ECLMJ2000: = new;
/// Rotation matrix from mean ecliptic J2000 to mean equatorial J2000.
///
/// Rotation of $+\varepsilon$ around the X-axis (transpose / inverse of
/// [`ROT_EQUMJ2000_TO_ECLMJ2000`]).
///
/// Equivalent to `rotpn(RefSystem::Eclm(RefEpoch::J2000), RefSystem::Equm(RefEpoch::J2000))`.
pub const ROT_ECLMJ2000_TO_EQUMJ2000: = new;
/// Modified Julian Date (Scale Ephemeris Time, ET)
pub type MJDET = f64;
/// Type alias for the RMS of normalized residuals from an IOD fit.
/// This is a single scalar value representing the overall fit quality of the IOD solution.
pub type IODRMS = f64;
/// Type alias for the chi-squared value of a fit, used in differential correction.
pub type Chi2 = f64;
/// Full batch orbit determination results.
///
/// Each entry maps an [`TrajId`] to the outcome of a full
/// Initial Orbit Determination (IOD) attempt on its set of observations.
///
/// Internally, this is implemented as:
///
/// ```ignore
/// HashMap<TrajId, Result<FitOrbitResult, OutfitError>, RandomState>
/// ```
///
/// Return semantics
/// -----------------
/// * `Ok(FitOrbitResult::IODGauss((GaussResult, IODRMS)))` – a successful IOD with its RMS of normalized residuals.
/// * `Ok(FitOrbitResult::DifferentialCorrection((OrbitalElements, Chi2)))` – a successful differential correction with its chi-squared value.
/// * `Err(OutfitError)` – a failure isolated to that object.
///
/// Use RandomState from the ahash crate for efficient hashing of TrajId keys.
pub type FullOrbitResult = ;