Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added AngularVelocity #135

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/si/angular_velocity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//! Angular Velocity (base unit radian per second, s⁻¹).

quantity! {
/// Angular Velocity (base unit radian per second, s⁻¹).
quantity: AngularVelocity; "angular velocity";
/// Dimension of angular velocity, T⁻¹ (base unit radian per second, s⁻¹).
dimension: ISQ<
Z0, // length
Z0, // mass
N1, // time
Z0, // electric current
Z0, // thermodynamic temperature
Z0, // amount of substance
Z0>; // luminous intensity
kind: ::si::marker::AngleKind;
units {
/// Derived unit of angular velocity.
@radian_per_second: 1.0; "rad/s", "radian per second", "radians per second";
@degree_per_second: 1.745_329_251_994_329_5_E-2; "°/s", "degree per second",
"degrees per second";
@revolution_per_second: 6.283_185_307_179_586_E0; "rps", "revolution per second",
"revolutions per second";
@revolution_per_minute: 1.047_197_551_196_597_7_E-1; "rpm", "revolution per minute",
"revolutions per minute";
@revolution_per_hour: 1.745_329_251_994_329_6_E-3; "rph", "revolution per hour",
"revolutions per hour";
}
}

#[cfg(test)]
mod tests {
storage_types! {
use num::One;
use si::angle as a;
use si::angular_velocity as v;
use si::quantities::*;
use si::time as t;
use tests::Test;

#[test]
fn check_units() {
test::<a::radian, t::second, v::radian_per_second>();
test::<a::degree, t::second, v::degree_per_second>();
test::<a::revolution, t::second, v::revolution_per_second>();
test::<a::revolution, t::minute, v::revolution_per_minute>();
test::<a::revolution, t::hour, v::revolution_per_hour>();

fn test<A: a::Conversion<V>, T: t::Conversion<V>, R: v::Conversion<V>>() {
Test::assert_approx_eq(&AngularVelocity::new::<R>(V::one()),
&(Angle::new::<A>(V::one()) / Time::new::<T>(V::one())).into());
}
}
}
}
1 change: 1 addition & 0 deletions src/si/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ system! {
acceleration::Acceleration,
amount_of_substance::AmountOfSubstance,
angle::Angle,
angular_velocity::AngularVelocity,
area::Area,
available_energy::AvailableEnergy,
capacitance::Capacitance,
Expand Down