diff --git a/src/si/mod.rs b/src/si/mod.rs index 175cddf6..fb1b7e8d 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -93,6 +93,7 @@ system! { pressure::Pressure, radiant_exposure::RadiantExposure, ratio::Ratio, + reciprocal_length::ReciprocalLength, solid_angle::SolidAngle, specific_heat_capacity::SpecificHeatCapacity, temperature_interval::TemperatureInterval, diff --git a/src/si/reciprocal_length.rs b/src/si/reciprocal_length.rs new file mode 100644 index 00000000..0f3fe633 --- /dev/null +++ b/src/si/reciprocal_length.rs @@ -0,0 +1,68 @@ +//! Reciprocal length (base unit reciprocal meter, m⁻¹). + +quantity! { + /// Reciprocal length (base unit reciprocal meter, m⁻¹). + quantity: ReciprocalLength; "reciprocal length"; + /// Dimension of reciprocal length, L⁻¹ (base unit reciprocal meter, m⁻¹). + dimension: ISQ< + N1, // length + Z0, // mass + Z0, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @reciprocal_kilometer: prefix!(none) / prefix!(kilo); "km⁻¹", + "reciprocal kilometer", "reciprocal kilometers"; + @reciprocal_meter: prefix!(none); "m⁻¹", + "reciprocal meter", "reciprocal meters"; + @reciprocal_decimeter: prefix!(none) / prefix!(deci); "dm⁻¹", + "reciprocal decimeter", "reciprocal decimeters"; + @reciprocal_centimeter: prefix!(none) / prefix!(centi); "cm⁻¹", + "reciprocal centimeter", "reciprocal centimeters"; + @reciprocal_millimeter: prefix!(none) / prefix!(milli); "mm⁻¹", + "reciprocal millimeter", "reciprocal millimeters"; + @reciprocal_micrometer: prefix!(none) / prefix!(micro); "µm⁻¹", + "reciprocal micrometer", "reciprocal micrometers"; + @reciprocal_nanometer: prefix!(none) / prefix!(nano); "nm⁻¹", + "reciprocal nanometer", "reciprocal nanometers"; + + @reciprocal_angstrom: prefix!(none) / 1.0_E-10; "Å⁻¹", + "reciprocal ångström", "reciprocal ångströms"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::length as l; + use crate::si::reciprocal_length as rl; + use crate::si::quantities::*; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: ReciprocalLength = V::one() + / Length::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + fn test, RL: rl::Conversion>() { + Test::assert_approx_eq(&ReciprocalLength::new::(V::one()), + &(V::one() / Length::new::(V::one()))); + } + } + } +}