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
use super::celestial::CelestialDynamics;
use super::deltavctrl::DeltaVctrl;
use super::Dynamics;
use crate::dimensions::{VectorN, U6};
use celestia::State;
pub struct MissionArc<'a, D: DeltaVctrl> {
pub celestial: CelestialDynamics<'a>,
pub ctrl: D,
}
impl<'a, D: DeltaVctrl> MissionArc<'a, D> {
pub fn new(celestial: CelestialDynamics<'a>, ctrl: D) -> Self {
Self { celestial, ctrl }
}
}
impl<'a, D: DeltaVctrl> Dynamics for MissionArc<'a, D> {
type StateSize = U6;
type StateType = State;
fn time(&self) -> f64 {
self.celestial.time()
}
fn state(&self) -> Self::StateType {
self.celestial.state()
}
fn state_vector(&self) -> VectorN<f64, Self::StateSize> {
self.celestial.state_vector()
}
fn set_state(&mut self, new_t: f64, new_state: &VectorN<f64, Self::StateSize>) {
self.celestial.set_state(new_t, new_state);
self.ctrl.next(&self.celestial.state());
}
fn eom(&self, t: f64, state: &VectorN<f64, Self::StateSize>) -> VectorN<f64, Self::StateSize> {
let mut d_x = self.celestial.eom(t, &state);
let eom_state = self.celestial.state_ctor(t, &state);
let dv_inertial = self.ctrl.ctrl_vector(&eom_state);
for i in 0..3 {
d_x[i + 3] = dv_inertial[i];
}
d_x
}
}