use-relativity 0.0.1

Small special relativity scalar helpers for RustUse
Documentation
  • Coverage
  • 100%
    35 out of 35 items documented11 out of 31 items with examples
  • Size
  • Source code size: 26.27 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 532.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-physics
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-relativity

Small special relativity scalar helpers for RustUse.

Install

[dependencies]
use-relativity = "0.0.1"

Foundation

use-relativity provides small special relativity scalar helpers for Lorentz factor, time dilation, length contraction, mass-energy relations, relativistic momentum, rapidity, velocity addition, and simple longitudinal Doppler calculations.

Inputs are expected to be SI-style numeric values:

  • meters per second for speed and velocity
  • seconds for time
  • meters for length
  • kilograms for mass
  • joules for energy
  • kilogram meters per second for momentum
  • hertz for frequency

Positive beta in the Doppler helpers means the source is approaching the observer.

This crate keeps SPEED_OF_LIGHT locally for convenience. Broader physical constants belong in the top-level use-constants set.

Unit abstractions belong in the top-level use-units set.

Example

use use_relativity::{RelativisticBody, SPEED_OF_LIGHT, beta, dilated_time, velocity_addition};

assert_eq!(beta(SPEED_OF_LIGHT * 0.5), Some(0.5));
assert!((dilated_time(10.0, SPEED_OF_LIGHT * 0.6).unwrap() - 12.5).abs() < 1.0e-12);
assert!((velocity_addition(SPEED_OF_LIGHT * 0.5, SPEED_OF_LIGHT * 0.5).unwrap()
    - (SPEED_OF_LIGHT * 0.8))
    .abs()
    < 1.0e-3);

let body = RelativisticBody::new(1.0, SPEED_OF_LIGHT * 0.6).unwrap();

assert!(body.total_energy().unwrap() > body.rest_energy().unwrap());

When to use directly

Choose use-relativity when you need small scalar special relativity helpers without a full unit, geometry, or simulation system.

Scope

  • APIs stay f64-first and focus on scalar special relativity helpers.
  • General relativity, tensor calculus, curved spacetime, and numerical simulation are out of scope.
  • Full constants systems and unit abstractions belong in use-constants and use-units.

Status

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