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§
- Angular
State - A scalar angular position and angular velocity pair.
- Rotating
Body - 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².