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
use super::na::{U3, U6, Vector3, Vector6, VectorN};
use super::Dynamics;
#[cfg(feature = "unvalidated")]
#[derive(Copy, Clone)]
pub struct BasicDrag {
pub rho: f64,
pub cd: f64,
pub area: f64,
pub mass: f64,
}
#[cfg(feature = "unvalidated")]
impl Dynamics for BasicDrag {
type StateSize = U6;
fn time(&self) -> f64 {
0.0
}
fn state(&self) -> VectorN<f64, Self::StateSize> {
Vector6::zeros()
}
fn set_state(&mut self, _new_t: f64, _new_state: &VectorN<f64, Self::StateSize>) {}
fn eom(&self, _t: f64, state: &VectorN<f64, Self::StateSize>) -> VectorN<f64, Self::StateSize> {
let velocity = state.fixed_rows::<U3>(3).into_owned();
let drag = -0.5 * (self.cd * self.area / self.mass) * self.rho * velocity.norm() * velocity;
Vector6::from_iterator(drag.iter().chain(Vector3::zeros().iter()).cloned())
}
}