@@ -51,8 +51,19 @@ pub use angle::Angle;
5151pub mod frequency;
5252pub use frequency:: Frequency ;
5353
54+ pub mod angular_velocity;
55+ pub use angular_velocity:: AngularVelocity ;
56+
57+ pub mod torque;
58+ pub use torque:: Torque ;
59+
5460pub mod prelude;
5561
62+ mod torque_energy;
63+ pub use torque_energy:: TorqueEnergy ;
64+
65+ pub mod test_utils;
66+
5667/// For given types A, B and C, implement, using base units:
5768/// - A = B * C
5869/// - A = C * B
@@ -129,13 +140,51 @@ impl Measurement for std::time::Duration {
129140}
130141
131142impl_maths ! ( Area , Length ) ;
132- impl_maths ! ( Energy , Force , Length ) ;
133143impl_maths ! ( Energy , std:: time:: Duration , Power ) ;
134144impl_maths ! ( Force , Mass , Acceleration ) ;
135145impl_maths ! ( Force , Pressure , Area ) ;
136146impl_maths ! ( Length , std:: time:: Duration , Speed ) ;
137147impl_maths ! ( Power , Force , Speed ) ;
138148impl_maths ! ( Speed , std:: time:: Duration , Acceleration ) ;
139149impl_maths ! ( Volume , Length , Area ) ;
150+ impl_maths ! ( Power , AngularVelocity , Torque ) ;
140151
141- pub mod test_utils;
152+ // Force * Distance is ambiguous. Create an ambiguous struct the user can then
153+ // cast into either Torque or Energy.
154+
155+ impl_maths ! ( TorqueEnergy , Force , Length ) ;
156+
157+ // Implement the divisions manually (the above macro only implemented the
158+ // TorqueEnergy / X operations).
159+
160+ impl :: std:: ops:: Div < Length > for Torque {
161+ type Output = Force ;
162+
163+ fn div ( self , rhs : Length ) -> Self :: Output {
164+ Self :: Output :: from_base_units ( self . as_base_units ( ) / rhs. as_base_units ( ) )
165+ }
166+ }
167+
168+ impl :: std:: ops:: Div < Force > for Torque {
169+ type Output = Length ;
170+
171+ fn div ( self , rhs : Force ) -> Self :: Output {
172+ Self :: Output :: from_base_units ( self . as_base_units ( ) / rhs. as_base_units ( ) )
173+ }
174+ }
175+
176+ impl :: std:: ops:: Div < Length > for Energy {
177+ type Output = Force ;
178+
179+ fn div ( self , rhs : Length ) -> Self :: Output {
180+ Self :: Output :: from_base_units ( self . as_base_units ( ) / rhs. as_base_units ( ) )
181+ }
182+ }
183+
184+ impl :: std:: ops:: Div < Force > for Energy {
185+ type Output = Length ;
186+
187+ fn div ( self , rhs : Force ) -> Self :: Output {
188+ Self :: Output :: from_base_units ( self . as_base_units ( ) / rhs. as_base_units ( ) )
189+ }
190+ }
0 commit comments