Skip to main content

Crate use_rigidbody

Crate use_rigidbody 

Source
Expand description

§use-rigidbody

Rigid-body mass properties and scalar mechanics helpers for RustUse.

§Install

[dependencies]
use-rigidbody = "0.0.1"

§Foundation

use-rigidbody provides small f64-first helpers for scalar rigid-body mechanics primitives: mass properties, center of mass, moments of inertia, kinetic energy, angular momentum, simple impulse response, and small rigid-body state helpers.

Inputs are expected to be SI-style numeric values:

  • kilograms for mass
  • meters for position, radius, length, and distance
  • meters per second for velocity
  • radians for angle
  • radians per second for angular velocity
  • kilogram square meters for moment of inertia
  • kilogram meters per second for linear momentum
  • kilogram square meters per second for angular momentum
  • joules for kinetic energy
  • newton-seconds for impulse

Vector mechanics should compose with use-vector.

Simulation loops belong in top-level use-simulation.

Collision-specific helpers belong in use-collision.

Rotation-specific helpers belong in use-rotation.

Torque-specific helpers belong in use-torque.

§Example

use use_rigidbody::{MassProperties, RigidBody1D, total_kinetic_energy};

let props = MassProperties::solid_sphere(5.0, 2.0).unwrap();
let body = RigidBody1D::new(props, 10.0, 3.0, 1.0, 5.0).unwrap();

assert_eq!(body.linear_momentum(), Some(15.0));
assert_eq!(body.rotational_kinetic_energy(), Some(100.0));
assert_eq!(total_kinetic_energy(5.0, 3.0, 8.0, 5.0), Some(122.5));

§When to use directly

Choose use-rigidbody when you need small, reusable scalar helpers for rigid-body mass properties, inertia, momentum, kinetic energy, and simple kinematic state updates.

§Scope

  • APIs stay f64-first and focus on scalar rigid-body mechanics primitives.
  • This crate is not a physics engine, collision detector, contact solver, constraint solver, game physics package, or simulation framework.
  • Vector rigid-body dynamics, joints, broad phase, narrow phase, and simulation loops are out of scope.

§Status

use-rigidbody is a pre-1.0 crate with a deliberately small API. Scalar rigid-body mechanics helpers.

Modules§

prelude
Convenient re-exports for the public rigid-body helpers.

Structs§

MassProperties
Mass and rotational inertia for a scalar rigid body.
RigidBody1D
A one-dimensional rigid body with scalar translational and rotational state.

Functions§

angular_impulse_from_angular_velocity_change
Computes angular impulse from an angular velocity change using J = I(ω_final - ω_initial).
angular_momentum
Computes angular momentum using L = Iω.
angular_velocity_after_angular_impulse
Computes final angular velocity after an angular impulse using ω_final = ω_initial + J / I.
center_moment_from_parallel_axis
Computes the center moment from a shifted moment using I_cm = I - md².
center_of_mass_1d
Computes the one-dimensional center of mass using x_cm = Σ(m_i * x_i) / Σm_i.
combined_mass
Computes the sum of non-negative masses.
hollow_sphere_moment_of_inertia
Computes hollow-sphere moment of inertia using I = (2 / 3)mr².
impulse_from_velocity_change
Computes impulse from a velocity change using J = m(v_final - v_initial).
linear_kinetic_energy
Computes translational kinetic energy using KE = 0.5mv².
linear_momentum
Computes linear momentum using p = mv.
parallel_axis_moment_of_inertia
Applies the parallel-axis theorem using I = I_cm + md².
point_mass_moment_of_inertia
Computes point-mass moment of inertia using I = mr².
reduced_mass
Computes reduced mass using μ = (m1 * m2) / (m1 + m2).
rod_moment_of_inertia_about_center
Computes rod moment of inertia about its center using I = (1 / 12)mL².
rod_moment_of_inertia_about_end
Computes rod moment of inertia about one end using I = (1 / 3)mL².
rotational_kinetic_energy
Computes rotational kinetic energy using KE_rot = 0.5Iω².
solid_disk_moment_of_inertia
Computes solid-disk moment of inertia using I = 0.5mr².
solid_sphere_moment_of_inertia
Computes solid-sphere moment of inertia using I = (2 / 5)mr².
thin_ring_moment_of_inertia
Computes thin-ring moment of inertia using I = mr².
total_kinetic_energy
Computes total kinetic energy using KE_total = 0.5mv² + 0.5Iω².
velocity_after_impulse
Computes final velocity after an impulse using v_final = v_initial + J / m.