xkcd_681.nbt 346 B

123456789101112
  1. # Gravity wells
  2. #
  3. # https://xkcd.com/681/
  4. use extra::astronomy
  5. fn well_depth(mass: Mass, radius: Length) -> Length =
  6. G × mass / (g0 × radius) -> km
  7. assert_eq(well_depth(earth_mass, earth_radius), 6379 km, 1 km)
  8. assert_eq(well_depth(mars_mass, mars_radius), 1286 km, 3 km)
  9. assert_eq(well_depth(lunar_mass, lunar_radius), 288 km, 1 km)