pub struct Universe {
pub time: f64,
pub time_step: f64,
pub g: f64,
/* private fields */
}Expand description
Struct that represents the simulation of the universe.
Fields§
§time: f64The time elapsed in the universe, in seconds.
time_step: f64The time step of the simulation, in seconds.
g: f64The gravitational constant, in m^3 kg^-1 s^-2.
Implementations§
Source§impl Universe
impl Universe
Sourcepub fn new_default() -> Universe
pub fn new_default() -> Universe
Creates an empty universe with default parameters.
Sourcepub fn add_body(&mut self, body: Body, satellite_of: Option<usize>) -> usize
pub fn add_body(&mut self, body: Body, satellite_of: Option<usize>) -> usize
Adds a body to the universe.
body: The body to add into the universe.
satellite_of: The index of the body that this body is orbiting.
Returns: The index of the newly-added body.
Sourcepub fn remove_body(&mut self, body_index: usize) -> Body
pub fn remove_body(&mut self, body_index: usize) -> Body
Removes a body from the universe.
body_index: The index of the body to remove.
Sourcepub fn get_bodies(&self) -> &Vec<Body>
pub fn get_bodies(&self) -> &Vec<Body>
Gets a Vec of all bodies in the universe.
Sourcepub fn get_body_relations(&self) -> &Vec<BodyRelation>
pub fn get_body_relations(&self) -> &Vec<BodyRelation>
Gets a Vec of all body relations in the universe.
Sourcepub fn get_body_mut(&mut self, index: usize) -> &mut Body
pub fn get_body_mut(&mut self, index: usize) -> &mut Body
Gets a mutable reference to a body in the universe.
Sourcepub fn get_body(&self, index: usize) -> &Body
pub fn get_body(&self, index: usize) -> &Body
Gets an immutable reference to a body in the unvierse.
Sourcepub fn get_first_body_index_with_name(&self, name: String) -> Option<usize>
pub fn get_first_body_index_with_name(&self, name: String) -> Option<usize>
Gets the index of the first body with a given name.
Sourcepub fn get_last_body_index_with_name(&self, name: String) -> Option<usize>
pub fn get_last_body_index_with_name(&self, name: String) -> Option<usize>
Gets the index of the last body with a given name.