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
//! Stellar aberration corrections for apparent-position computation.
//!
//! This module provides two levels of aberration correction:
//!
//! | Function | Description |
//! |---|---|
//! | [`correct_aberration_first_order`] | Linear light-travel-time shift |
//! | [`correct_aberration_second_order`] | Two-step Keplerian back-propagation |
//!
//! The correction to apply is selected at call-site via
//! [`AberrationOrder`](super::AberrationOrder).
//!
//! # Physical background
//!
//! When an observer detects a photon, the emitting body has already moved on.
//! The apparent direction corresponds to the body's position at the **retarded
//! epoch** — the moment the photon was emitted, not the moment it was received.
//!
//! Both corrections account for this light-travel delay; they differ in how
//! accurately they approximate the retarded position:
//!
//! - **First order** computes the delay from the instantaneous separation and
//! subtracts a *linear* displacement along the current velocity. Accurate to
//! \\( O(v/c) \\).
//!
//! - **Second order** iterates the delay twice and back-propagates the orbit
//! along the **Keplerian two-body solution** at each step, capturing the
//! orbital curvature during the light-travel time. Necessary for sub-mas
//! accuracy on close-approach objects or highly curved orbits.
//!
//! # Coordinate conventions
//!
//! All vectors are in the **equatorial mean J2000** frame, positions in AU,
//! velocities in AU/day.
use Vector3;
use crate::;
// ---------------------------------------------------------------------------
// Aberration order
// ---------------------------------------------------------------------------
/// Stellar aberration correction order applied during apparent-position
/// computation.
///
/// Controls whether the pipeline uses the fast linear approximation or the
/// more accurate two-step Keplerian back-propagation.
///
/// For the vast majority of targets (main-belt asteroids, typical NEOs) the
/// difference between the two corrections is sub-milliarcsecond and
/// [`AberrationOrder::First`] is sufficient. [`AberrationOrder::Second`]
/// becomes relevant for close-approach objects (geocentric distance
/// \\( \lesssim 0.01 \\) AU) or highly curved orbits where the linear
/// approximation breaks down.
///
/// See `correct_aberration_first_order` and `correct_aberration_second_order`
/// for the implementation of both corrections.
// ---------------------------------------------------------------------------
// First-order correction
// ---------------------------------------------------------------------------
/// Apply the **first-order** stellar aberration correction to a topocentric
/// position vector.
///
/// The apparent direction is obtained by subtracting the linear displacement
/// of the body during the light-travel time \\( \Delta t = |\mathbf{d}| / c \\):
///
/// $$\mathbf{d}_\text{corr} = \mathbf{d} - \frac{|\mathbf{d}|}{c}\,\mathbf{v}_\text{body}$$
///
/// where \\( c \\) is the speed of light in AU/day ([`VLIGHT_AU`]).
///
/// This approximation is valid for the vast majority of solar system targets
/// (main-belt asteroids, typical NEOs). The residual error with respect to
/// the exact retarded position is of order \\( O((v/c)^2) \\), sub-mas for
/// most objects.
///
/// # Arguments
///
/// - `topocentric_vec` – Vector from observer to body \\( \mathbf{d} \\) \[AU\],
/// equatorial mean J2000.
/// - `body_velocity` – Body heliocentric velocity \\( \mathbf{v} \\) \[AU/day\],
/// equatorial mean J2000.
///
/// # Returns
///
/// Aberration-corrected topocentric direction vector \[AU\]. The magnitude is
/// slightly different from the input; only the direction is used downstream.
pub
// ---------------------------------------------------------------------------
// Second-order correction
// ---------------------------------------------------------------------------
/// Apply the **second-order** stellar aberration correction via two-step
/// Keplerian back-propagation.
///
/// Rather than shifting the current position linearly, this function
/// propagates the orbit *backwards* by the estimated light-travel time, twice
/// in succession, to recover the retarded position with sub-mas accuracy.
///
/// ## Algorithm
///
/// Let \\( \mathbf{d}_0 = \mathbf{r}_\text{body} - \mathbf{r}_\text{obs} \\)
/// be the instantaneous topocentric vector.
///
/// **Pass 1:**
/// $$\Delta t_0 = |\mathbf{d}_0| / c$$
/// $$\mathbf{r}_1 = \text{propagate\_twobody}(t_\text{obs} - \Delta t_0)$$
/// $$\mathbf{d}_1 = \mathbf{r}_1 - \mathbf{r}_\text{obs}$$
///
/// **Pass 2:**
/// $$\Delta t_1 = |\mathbf{d}_1| / c$$
/// $$\mathbf{r}_2 = \text{propagate\_twobody}(t_\text{obs} - \Delta t_1)$$
///
/// **Result:**
/// $$\mathbf{d}_\text{corr} = \mathbf{r}_2 - \mathbf{r}_\text{obs}$$
///
/// The two-body propagator is used for both passes regardless of the main
/// propagator choice in [`EphemerisConfig`](super::EphemerisConfig).
///
/// # Arguments
///
/// - `topocentric_vec` – Instantaneous topocentric vector \\( \mathbf{d}_0 \\)
/// \[AU\], equatorial mean J2000.
/// - `elements` – Equinoctial orbital elements at their reference epoch.
/// - `obs_time_mjd` – Observation epoch \[MJD TT\].
/// - `obs_pos_equ` – Observer heliocentric position \[AU\], equatorial
/// mean J2000.
///
/// # Returns
///
/// Aberration-corrected topocentric direction vector \[AU\].
///
/// # Errors
///
/// Returns [`OutfitError`] if either two-body propagation step fails to
/// converge (e.g. degenerate orbit).
pub
// ---------------------------------------------------------------------------
// Private helper
// ---------------------------------------------------------------------------
/// Back-propagate the orbit by a light-travel time derived from `separation`
/// and return the body's heliocentric position at the retarded epoch, in the
/// **equatorial mean J2000** frame \[AU\].
///
/// Computes the retarded epoch as
/// \\( t_\text{ret} = t_\text{obs} - |\text{separation}| / c \\)
/// and calls [`EquinoctialElements::propagate_twobody`].
///
/// # Errors
///
/// Returns [`OutfitError`] if the Kepler solver does not converge.