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

Add AngularMomentum #463

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
42 changes: 42 additions & 0 deletions src/si/angular_momentum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//! Angular momentum (base unit kilogram square meter per second, kg · m² · s⁻¹).

quantity! {
/// Angular momentum (base unit kilogram square meter per second, kg · m² · s⁻¹).
quantity: AngularMomentum; "angular momentum";
/// Dimension of angular momentum, L²MT⁻¹ (base unit kilogram square meter per second, kg · m² · s⁻¹).
dimension: ISQ<
P2, // length
P1, // mass
N1, // time
Z0, // electric current
Z0, // thermodynamic temperature
Z0, // amount of substance
Z0>; // luminous intensity
kind: dyn (crate::si::marker::AngleKind);
units {
/// Derived unit of angular velocity.
@kilogram_square_meter_per_second: 1.0_E0; "kg m^2/s", "kilogram square meter per second", "kilogram square meters per second";
}
}

#[cfg(test)]
mod tests {
storage_types! {
use crate::num::One;
use crate::si::moment_of_inertia as p;
use crate::si::angular_velocity as v;
use crate::si::quantities::*;
use crate::si::angular_momentum as l;
use crate::tests::Test;

#[test]
fn check_units() {
test::<l::kilogram_square_meter_per_second, p::kilogram_square_meter, v::radian_per_second>();

fn test<L: l::Conversion<V>, P: p::Conversion<V>, R: v::Conversion<V>>() {
Test::assert_approx_eq(&AngularMomentum::new::<L>(V::one()),
&(MomentOfInertia::new::<P>(V::one()) * AngularVelocity::new::<R>(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 @@ -53,6 +53,7 @@ system! {
angular_absement::AngularAbsement,
angular_acceleration::AngularAcceleration,
angular_jerk::AngularJerk,
angular_momentum::AngularMomentum,
angular_velocity::AngularVelocity,
area::Area,
areal_density_of_states::ArealDensityOfStates,
Expand Down