Skip to content

Commit

Permalink
Update function names for circular orbit (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
iancleary authored Feb 13, 2024
1 parent 16507aa commit b5491cd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/orbits/circular.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::constants::GRAVITATIONAL_CONSTANT;

pub fn circular_orbital_speed(mass_of_body: f64, distance_from_center_of_body: f64) -> f64 {
pub fn calculate_circular_orbit_speed(mass_of_body: f64, distance_from_center_of_body: f64) -> f64 {
// F = G*M*m/ r^2 = mv^2/r

// G*M = mv^2/r
Expand All @@ -15,7 +15,7 @@ pub fn circular_orbital_speed(mass_of_body: f64, distance_from_center_of_body: f
orbital_speed
}

pub fn circular_orbital_period(mass_of_body: f64, distance_from_center_of_body: f64) -> f64 {
pub fn calculate_circular_orbit_period(mass_of_body: f64, distance_from_center_of_body: f64) -> f64 {
// T = 2*pi*sqrt(r^3/G*M)
// Returns the orbital period in seconds

Expand Down Expand Up @@ -52,7 +52,7 @@ mod tests {
let distance_from_center_of_body: f64 = altitude + RADIUS_OF_EARTH;

let orbital_speed: f64 =
super::circular_orbital_speed(MASS_OF_EARTH, distance_from_center_of_body);
super::calculate_circular_orbit_speed(MASS_OF_EARTH, distance_from_center_of_body);

// m/s
assert_eq!(7353.592432681345, orbital_speed);
Expand All @@ -64,7 +64,7 @@ mod tests {
let altitude: f64 = 1.0 * base.powf(6.0); // 1_000 km altitude
let distance_from_center_of_body: f64 = altitude + RADIUS_OF_EARTH;

let orbital_period: f64 = super::circular_orbital_period(MASS_OF_EARTH, distance_from_center_of_body);
let orbital_period: f64 = super::calculate_circular_orbit_period(MASS_OF_EARTH, distance_from_center_of_body);

// seconds
assert_eq!(6298.058985889903, orbital_period);
Expand All @@ -81,7 +81,7 @@ mod tests {
let altitude: f64 = 2.0 * base.powf(6.0); // 2_000 km altitude
let distance_from_center_of_body: f64 = altitude + RADIUS_OF_EARTH;

let orbital_period: f64 = super::circular_orbital_period(MASS_OF_EARTH, distance_from_center_of_body);
let orbital_period: f64 = super::calculate_circular_orbit_period(MASS_OF_EARTH, distance_from_center_of_body);

// seconds
assert_eq!(7622.248787682895, orbital_period);
Expand Down

0 comments on commit b5491cd

Please sign in to comment.