Orbit picker: functions to calculate forces and Roche limits
[?]
Jun 16, 2021, 3:21 AM
44YVVUNCI6DMMP6SF7LCBGWDYFAENLRKZ5TUMRSB62YOCL5QXBLACDependencies
- [2]
PNOS6DEIOrbit picker: move vector stuff to its own module and add more impls - [3]
EWUP525BBasic vector arithmetic for the orbit picker - [4]
K3V2JNKCInitialize sub-project for choosing lunar orbital parameters - [5]
4LTVYHHIAdd async runtime for the orbital parameter picker
Change contents
- replacement in orbitpick/src/vec3.rs at line 1
#[derive(Copy,Clone,Debug)]#[derive(Copy, Clone, Debug, PartialEq)] - replacement in orbitpick/src/vec3.rs at line 5
pub z: f64pub z: f64, - replacement in orbitpick/src/vec3.rs at line 103
(self.x*self.x + self.y*self.y + self.z*self.z).sqrt()(self.x * self.x + self.y * self.y + self.z * self.z).sqrt() - file addition: nbody.rs[3.19]
use crate::vec3::V3;use std::f64::consts::PI;pub const G: f64 = 6.67430e-11;#[derive(Debug, Clone, Copy)]pub struct Body {pub mass: f64,pub position: V3,pub velocity: V3,pub radius: f64,}impl Body {pub fn momentum(&self) -> V3 {self.velocity * self.mass}pub fn density(&self) -> f64 {self.mass / (4. / 3. * PI * self.radius * self.radius * self.radius)}pub fn roche_limit(&self, other: &Self, variant: RocheLimitType) -> f64 {self.radius* (2. * self.density() / other.density()).powf(1. / 3.)* match variant {RocheLimitType::Rigid => 1.,RocheLimitType::Fluid => 2.44,}}}pub enum RocheLimitType {Rigid,Fluid,}pub fn forces(state: Vec<Body>) -> Vec<V3> {let mut result = vec![V3 {x: 0.,y: 0.,z: 0.};state.len()];for (ix, xb) in state.iter().enumerate() {for (iy, yb) in state.iter().enumerate() {if ix != iy {let d = yb.position - xb.position;let r2 = d.x * d.x + d.y * d.y + d.z * d.z;let f = xb.mass * yb.mass / r2;result[ix] += d.normalize() * f;}}}for b in result.iter_mut() {*b *= G;}result} - edit in orbitpick/src/main.rs at line 3
mod nbody; - replacement in orbitpick/src/main.rs at line 9
println!("Hello, world!");println!("{}", nbody::G);