Search code examples
c++boostboost-units

Boost: typedef for rpm


I'm trying to use boost::units in my code to define a type RoundsPerMinute. However I am not really understanding how to do that.

I've defined a minute via

using boost::units::si::seconds;

typedef boost::units::make_scaled_unit < boost::units::si::time, boost::units::scale<60, boost::units::static_rational<1> > >::type minute;
BOOST_UNITS_STATIC_CONSTANT(minutes, minute);

typedef boost::units::quantity<minute, float> Minute;

and can now do e.g.

Minute m = 5*minutes;

What I now would like to do is something along the lines of

RoundsPerMinute rpm1 = 50 * rpm;
RoundsPerMinute rpm2 = 100 / (2*minutes);
Minute m = 1/rpm2; // how many minutes does it take for one round?

but I am not sure how to define these types - frankly the whole boost documentation is way too technical for me to understand :-( If anybody could help me out with the definitions, this would be great.


Solution

  • One RPM is just 1/60 Hertz - see boost::units::si::hertz.