Skip to content

Commit 5050d98

Browse files
committed
Merge pull request #135 from dunmatt/angular
Add `AngularVelocity`.
2 parents bc5a344 + 0a730a7 commit 5050d98

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

src/si/angle.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ mod convert {
6262
mod tests {
6363
storage_types! {
6464
use ::lib::f64::consts::PI;
65-
use num::One;
66-
use num_traits::FromPrimitive;
65+
use num::{FromPrimitive, One};
6766
use si::angle as a;
6867
use si::quantities::*;
6968
use tests::Test;

src/si/angular_velocity.rs

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//! Angular velocity (base unit radian per second, s⁻¹).
2+
3+
quantity! {
4+
/// Angular velocity (base unit radian per second, s⁻¹).
5+
quantity: AngularVelocity; "angular velocity";
6+
/// Dimension of angular velocity, T⁻¹ (base unit radian per second, s⁻¹).
7+
dimension: ISQ<
8+
Z0, // length
9+
Z0, // mass
10+
N1, // time
11+
Z0, // electric current
12+
Z0, // thermodynamic temperature
13+
Z0, // amount of substance
14+
Z0>; // luminous intensity
15+
kind: ::si::marker::AngleKind;
16+
units {
17+
/// Derived unit of angular velocity.
18+
@radian_per_second: 1.0_E0; "rad/s", "radian per second", "radians per second";
19+
@degree_per_second: 1.745_329_251_994_329_5_E-2; "°/s", "degree per second",
20+
"degrees per second";
21+
@revolution_per_second: 6.283_185_307_179_586_E0; "rps", "revolution per second",
22+
"revolutions per second";
23+
@revolution_per_minute: 1.047_197_551_196_597_7_E-1; "rpm", "revolution per minute",
24+
"revolutions per minute";
25+
@revolution_per_hour: 1.745_329_251_994_329_6_E-3; "rph", "revolution per hour",
26+
"revolutions per hour";
27+
}
28+
}
29+
30+
#[cfg(test)]
31+
mod tests {
32+
storage_types! {
33+
use num::One;
34+
use si::angle as a;
35+
use si::angular_velocity as v;
36+
use si::quantities::*;
37+
use si::time as t;
38+
use tests::Test;
39+
40+
#[test]
41+
fn check_units() {
42+
test::<a::radian, t::second, v::radian_per_second>();
43+
test::<a::degree, t::second, v::degree_per_second>();
44+
test::<a::revolution, t::second, v::revolution_per_second>();
45+
test::<a::revolution, t::minute, v::revolution_per_minute>();
46+
test::<a::revolution, t::hour, v::revolution_per_hour>();
47+
48+
fn test<A: a::Conversion<V>, T: t::Conversion<V>, R: v::Conversion<V>>() {
49+
Test::assert_approx_eq(&AngularVelocity::new::<R>(V::one()),
50+
&(Angle::new::<A>(V::one()) / Time::new::<T>(V::one())).into());
51+
}
52+
}
53+
}
54+
}

src/si/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ system! {
3939
amount_of_substance::AmountOfSubstance,
4040
angle::Angle,
4141
angular_acceleration::AngularAcceleration,
42+
angular_velocity::AngularVelocity,
4243
area::Area,
4344
available_energy::AvailableEnergy,
4445
capacitance::Capacitance,

0 commit comments

Comments
 (0)