Expand description
§use-gravity
Gravity-specific helpers for RustUse.
§Install
[dependencies]
use-gravity = "0.0.1"§Foundation
use-gravity provides small f64-first helpers for gravitational force, gravitational acceleration, orbital velocity, escape velocity, orbital period, and gravitational potential energy.
Inputs are expected to be SI-style numeric values:
- kilograms for mass
- meters for distance, radius, and height
- seconds for time
- newtons for force
- joules for energy
§Example
use use_gravity::{GravityBody, escape_velocity, gravitational_force};
let earth = GravityBody::new(5.972e24, 6.371e6).unwrap();
let force = gravitational_force(1.0, 1.0, 1.0).unwrap();
let escape = escape_velocity(5.972e24, 6.371e6).unwrap();
assert_eq!(force, use_gravity::GRAVITATIONAL_CONSTANT);
assert!(earth.surface_gravity().unwrap() > 9.8);
assert!(escape > 11_000.0);§When to use directly
Choose use-gravity when you only need reusable gravity and orbit formulas.
§Scope
- APIs stay
f64-first and do not define a full unit system. - The crate keeps only a couple of convenience constants locally.
- Broader constants and units belong in the top-level
use-constantsanduse-unitssets.
§Status
use-gravity is a pre-1.0 crate with a deliberately small API.
Gravity, orbit, and gravitational energy helpers.
Modules§
Structs§
- Gravity
Body - Mass and radius for a body used in gravity calculations.
Constants§
- GRAVITATIONAL_
CONSTANT - Newtonian constant of gravitation, in cubic meters per kilogram second squared.
- STANDARD_
GRAVITY - Conventional standard gravity, in meters per second squared.
Functions§
- circular_
orbital_ period - Computes the orbital period for a circular orbit.
- circular_
orbital_ velocity - Computes the circular orbital velocity around a source mass.
- escape_
velocity - Computes the escape velocity from a source mass at a distance.
- gravitational_
acceleration - Computes the gravitational acceleration caused by a source mass at a distance.
- gravitational_
force - Computes the gravitational attraction between two point masses.
- gravitational_
potential_ energy - Computes gravitational potential energy between two masses.
- near_
surface_ potential_ energy - Computes near-surface potential energy from mass, height, and gravitational acceleration.
- standard_
weight - Computes weight under conventional standard gravity.
- weight
- Computes weight from mass and gravitational acceleration.