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
use crate::dimensions::Vector3;
use celestia::{Frame, State};
pub use super::thrustctrl::Mnvr;
pub trait DeltaVctrl
where
Self: Clone + Sized,
{
fn ctrl_vector(&self, state: &State) -> Vector3<f64>;
fn next(&mut self, state: &State);
}
#[derive(Clone, Debug)]
pub struct InstantBurns {
pub mnvrs: Vec<Mnvr>,
pub mnvr_no: usize,
}
impl InstantBurns {
pub fn from_mnvrs(mnvrs: Vec<Mnvr>) -> Self {
Self { mnvrs, mnvr_no: 0 }
}
}
impl DeltaVctrl for InstantBurns {
fn ctrl_vector(&self, state: &State) -> Vector3<f64> {
if self.mnvr_no >= self.mnvrs.len() {
Vector3::zeros()
} else {
let next_mnvr = self.mnvrs[self.mnvr_no];
if next_mnvr.start <= state.dt && next_mnvr.end >= state.dt {
state.dcm_to_inertial(Frame::VNC) * next_mnvr.vector
} else {
Vector3::zeros()
}
}
}
fn next(&mut self, state: &State) {
if self.mnvr_no < self.mnvrs.len() {
let cur_mnvr = self.mnvrs[self.mnvr_no];
if state.dt >= cur_mnvr.end {
self.mnvr_no += 1;
}
}
}
}