Skip to main content

Crate use_momentum

Crate use_momentum 

Source
Expand description

§use-momentum

Linear momentum, impulse, and recoil helpers for RustUse.

§Install

[dependencies]
use-momentum = "0.0.1"

§Foundation

use-momentum provides small f64-first helpers for linear momentum and impulse calculations.

Inputs are expected to be SI-style numeric values:

  • kilograms for mass
  • meters per second for velocity
  • kilogram meters per second for momentum
  • newton seconds for impulse
  • seconds for time

The crate does not define a full unit system.

§Example

use use_momentum::{MovingMass, impulse, momentum, recoil_velocity};

assert_eq!(momentum(2.0, 3.0), Some(6.0));

assert_eq!(impulse(10.0, 2.0), Some(20.0));

assert_eq!(recoil_velocity(1.0, 10.0, 5.0), Some(-2.0));
assert_eq!(MovingMass::new(2.0, 3.0).unwrap().momentum(), Some(6.0));

§When to use directly

Choose use-momentum when you need small, reusable helpers for scalar momentum, impulse, and recoil.

§Scope

  • APIs stay f64-first and focus on one-dimensional scalar helpers.
  • One-dimensional collision outcomes and restitution helpers belong in use-collision.
  • Higher-dimensional vector operations should live in or compose with use-vector.
  • Full rigid-body simulation and broader physics engines are out of scope.

§Status

use-momentum is a pre-1.0 crate with a deliberately small API. Linear momentum, impulse, and recoil helpers.

Modules§

prelude

Structs§

MovingMass
A moving mass with scalar velocity.

Functions§

average_force_from_impulse
Computes average force from impulse and elapsed time using F = J / Δt.
impulse
Computes impulse from force and elapsed time using J = F * Δt.
impulse_from_momentum_change
Computes impulse from a change in momentum using J = p_final - p_initial.
mass_from_momentum
Computes mass from momentum and velocity using m = p / v.
momentum
Computes linear momentum using p = m * v.
recoil_velocity
Computes recoil velocity assuming the initial total momentum is zero.
total_momentum
Computes the total momentum of a slice of momentum values.
two_body_total_momentum
Computes the total momentum of two moving bodies using p_total = m1v1 + m2v2.
velocity_from_momentum
Computes velocity from momentum and mass using v = p / m.