Expand description
§scirs-units
Unit conversion and dimensional analysis for scientific computing.
This crate provides:
- SI base and derived units
- Common unit conversions
- Dimensional analysis with compile-time checking (optional)
- Physical quantity types with associated units
§Usage
use yatrosci_units::prelude::*;
// Basic unit conversions
let meters = Length::meters(1000.0);
let kilometers = meters.to_kilometers();
assert!((kilometers.value() - 1.0).abs() < 1e-10);
// Temperature conversions
let celsius = Temperature::celsius(100.0);
let kelvin = celsius.to_kelvin();
assert!((kelvin.value() - 373.15).abs() < 1e-10);§Dimensional Analysis
The crate supports dimensional analysis to ensure physical correctness:
use yatrosci_units::{Dimension, Quantity};
// Length dimension: L^1
let length = Quantity::new(5.0, Dimension::length());
// Area = Length * Length: L^2
let area = length.clone() * length;
assert_eq!(area.dimension().length_power(), 2);Re-exports§
Modules§
- acceleration
- Acceleration quantity type
- amount
- Amount of substance quantity type
- conversion
- Unit conversion utilities
- current
- Electric current quantity type
- dimension
- Dimensional analysis types
- electric
- Electric quantity types
- energy
- Energy quantity type
- force
- Force quantity type
- frequency
- Frequency quantity type
- length
- Length quantity type
- luminosity
- Luminous intensity quantity type
- mass
- Mass quantity type
- power
- Power quantity type
- prelude
- Prelude module for convenient imports
- pressure
- Pressure quantity type
- quantity
- Generic physical quantity type
- si
- SI unit definitions and prefixes
- temperature
- Temperature quantity type
- time
- Time quantity type
- velocity
- Velocity quantity type