Skip to main content

Crate use_rotation

Crate use_rotation 

Source
Expand description

§use-rotation

Rotational motion, angular momentum, and moment-of-inertia helpers for RustUse.

§Install

[dependencies]
use-rotation = "0.0.1"

§Foundation

use-rotation provides small f64-first helpers for rotational motion and rotational dynamics.

Inputs are expected to be SI-style numeric values:

  • radians for angular displacement
  • radians per second for angular velocity
  • radians per second squared for angular acceleration
  • meters for radius and length
  • kilograms for mass
  • kilogram square meters for moment of inertia
  • kilogram square meters per second for angular momentum
  • joules for rotational kinetic energy
  • newton-meters for torque

The crate does not define a full unit system.

Vector operations should live in or compose with use-vector.

Torque-specific scalar helpers belong in use-torque.

§Example

use use_rotation::{
    AngularState, RotatingBody, angular_velocity, rotational_kinetic_energy,
    solid_disk_moment_of_inertia, tangential_speed,
};

assert_eq!(angular_velocity(10.0, 2.0), Some(5.0));
assert_eq!(tangential_speed(3.0, 2.0), Some(6.0));
assert_eq!(solid_disk_moment_of_inertia(2.0, 3.0), Some(9.0));
assert_eq!(rotational_kinetic_energy(4.0, 5.0), Some(50.0));

let body = RotatingBody::new(4.0, 5.0).unwrap();
assert_eq!(body.angular_momentum(), Some(20.0));

let state = AngularState::new(1.0, 2.0)
    .unwrap()
    .advanced_by_constant_acceleration(3.0, 4.0)
    .unwrap();

assert_eq!(state.angular_position, 33.0);
assert_eq!(state.angular_velocity, 14.0);

§When to use directly

Choose use-rotation when you need small, reusable helpers for scalar angular motion, angular momentum, rotational energy, centripetal relations, and common moments of inertia.

§Scope

  • APIs stay f64-first and focus on scalar rotational helpers.
  • Higher-dimensional vector operations should live in or compose with use-vector.
  • Broad torque-specific helper APIs belong in use-torque.
  • Full rigid-body dynamics, tensors, and simulation engines are out of scope.

§Status

use-rotation is a pre-1.0 crate with a deliberately small API.

Modules§

prelude
Convenient re-exports for the public rotation helpers.

Structs§

AngularState
A scalar angular position and angular velocity pair.
RotatingBody
A rotating body with scalar moment of inertia and angular velocity.

Functions§

angular_acceleration
Computes angular acceleration using α = (ω_final - ω_initial) / t.
angular_acceleration_from_torque
Computes angular acceleration from torque using α = τ / I.
angular_displacement
Computes angular displacement using θ = ω_initial * t + 0.5 * α * t².
angular_momentum
Computes angular momentum using L = Iω.
angular_velocity
Computes angular velocity using ω = Δθ / t.
angular_velocity_from_angular_momentum
Computes angular velocity from angular momentum using ω = L / I.
angular_velocity_from_rotational_kinetic_energy
Computes angular velocity from rotational kinetic energy using ω = sqrt(2KE / I).
angular_velocity_from_tangential_speed
Computes angular velocity from tangential speed using ω = v / r.
centripetal_acceleration_from_angular_velocity
Computes centripetal acceleration using a_c = ω²r.
centripetal_acceleration_from_tangential_speed
Computes centripetal acceleration using a_c = v² / r.
degrees_from_radians
Converts radians to degrees.
final_angular_velocity
Computes final angular velocity using ω_final = ω_initial + αt.
final_angular_velocity_from_displacement
Computes final angular velocity using ω_final = sqrt(ω_initial² + 2αθ).
final_angular_velocity_squared
Computes squared final angular velocity using ω_final² = ω_initial² + 2αθ.
hollow_sphere_moment_of_inertia
Computes hollow-sphere moment of inertia using I = (2 / 3)mr².
point_mass_moment_of_inertia
Computes point-mass moment of inertia using I = mr².
radians_from_degrees
Converts degrees to radians.
radians_from_revolutions
Converts revolutions to radians.
revolutions_from_radians
Converts radians to revolutions.
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.5 * I * ω².
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².
tangential_acceleration
Computes tangential acceleration using a_t = αr.
tangential_speed
Computes tangential speed using v = ωr.
thin_ring_moment_of_inertia
Computes thin-ring moment of inertia using I = mr².