sidereon_core/astro/
state.rs1use nalgebra::Vector3;
2
3#[derive(Debug, Clone, Copy, PartialEq)]
4pub struct CartesianState {
5 pub epoch_tdb_seconds: f64,
6 pub position_km: Vector3<f64>,
7 pub velocity_km_s: Vector3<f64>,
8}
9
10impl CartesianState {
11 pub fn new(epoch_tdb_seconds: f64, position: [f64; 3], velocity: [f64; 3]) -> Self {
12 Self {
13 epoch_tdb_seconds,
14 position_km: Vector3::from_column_slice(&position),
15 velocity_km_s: Vector3::from_column_slice(&velocity),
16 }
17 }
18
19 pub fn position_array(&self) -> [f64; 3] {
20 [self.position_km.x, self.position_km.y, self.position_km.z]
21 }
22
23 pub fn velocity_array(&self) -> [f64; 3] {
24 [
25 self.velocity_km_s.x,
26 self.velocity_km_s.y,
27 self.velocity_km_s.z,
28 ]
29 }
30}
31
32#[derive(Debug, Clone, Copy)]
33pub struct StateDerivative {
34 pub dpos_km_s: Vector3<f64>,
35 pub dvel_km_s2: Vector3<f64>,
36}
37
38impl StateDerivative {
39 pub fn new(dpos: Vector3<f64>, dvel: Vector3<f64>) -> Self {
40 Self {
41 dpos_km_s: dpos,
42 dvel_km_s2: dvel,
43 }
44 }
45}