@@ -12,7 +12,10 @@ use hifitime::{Epoch, Unit as TimeUnit};
12
12
use snafu:: ResultExt ;
13
13
14
14
use crate :: {
15
- constants:: orientations:: J2000 ,
15
+ constants:: {
16
+ frames:: { EARTH_J2000 , SUN_J2000 } ,
17
+ orientations:: J2000 ,
18
+ } ,
16
19
errors:: { AlmanacResult , EphemerisSnafu , OrientationSnafu } ,
17
20
math:: { cartesian:: CartesianState , units:: LengthUnit , Vector3 } ,
18
21
orientations:: OrientationPhysicsSnafu ,
@@ -178,4 +181,35 @@ impl Almanac {
178
181
action : "transform provided state" ,
179
182
} )
180
183
}
184
+
185
+ /// Returns the unitary 3D vector between two [Frame]s (solid bodies) at desired [Epoch]
186
+ pub fn unit_vector (
187
+ & self ,
188
+ target_frame : Frame ,
189
+ observer_frame : Frame ,
190
+ epoch : Epoch ,
191
+ ab_corr : Option < Aberration > ,
192
+ ) -> AlmanacResult < Vector3 > {
193
+ let state = self . transform ( target_frame, observer_frame, epoch, ab_corr) ?;
194
+ Ok ( state. radius_km / state. rmag_km ( ) )
195
+ }
196
+
197
+ /// Returns the unitary 3D vector between desired [Frame] (solid body) and the Sun at desired [Epoch]
198
+ pub fn sun_unit_vector (
199
+ & self ,
200
+ epoch : Epoch ,
201
+ observer_frame : Frame ,
202
+ ab_corr : Option < Aberration > ,
203
+ ) -> AlmanacResult < Vector3 > {
204
+ self . unit_vector ( SUN_J2000 , observer_frame, epoch, ab_corr)
205
+ }
206
+
207
+ /// Returns the unitary 3D vector between Earth and Sun at desired [Epoch].
208
+ pub fn earth_sun_unit_vector (
209
+ & self ,
210
+ epoch : Epoch ,
211
+ ab_corr : Option < Aberration > ,
212
+ ) -> AlmanacResult < Vector3 > {
213
+ self . unit_vector ( SUN_J2000 , EARTH_J2000 , epoch, ab_corr)
214
+ }
181
215
}
0 commit comments