Hi community,
while the code below works, i am not sure if it is the best/most elegant approach.
Specifically,
a) can i somehow reuse the minute_base_unit from SI (rpm=dimensionless/minute_base_unit)?
b) Is the cast to quantity<frequency> in velocity calculation avoidable, e.g. can be done automatically?
Thanks in advance.
Dennis
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <boost/units/systems/si.hpp>
#include <boost/units/systems/si/io.hpp>
#include <boost/units/systems/si/prefixes.hpp>
#include <boost/units/base_units/metric/minute.hpp>
using namespace boost::units;
using namespace boost::units::si;
using namespace boost::units::metric;
using namespace std;
BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(si, revolution, revolutions per minute", "rpm", 1.0/60.0, frequency, 1);
typedef revolution_base_unit::unit_type revolution;
BOOST_UNITS_STATIC_CONSTANT(rpm, revolution);
BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(si, velocity_kmh, "velocity", "km/h", 1.0/3.6, velocity, 2);
typedef velocity_kmh_base_unit::unit_type velocity_kmh;
BOOST_UNITS_STATIC_CONSTANT(kmh, velocity_kmh);
int main(int argc, char* argv[])
{
quantity<velocity> v(0.0 * meter_per_second);
quantity<length> r(0.63 * meter);
quantity<dimensionless> i_HA(4.5 * si_dimensionless);
quantity<dimensionless> i_G(1.0 * si_dimensionless);
quantity<revolution> n(3000.0 * rpm);
quantity<dimensionless> pi2(2.0 * M_PI * si_dimensionless);
cout << n << endl;
v = ((quantity<frequency>)n / (i_HA * i_G)) * pi2 * r;
cout << v << endl;
quantity<velocity_kmh> v2(v);
cout << v2 << endl;
return 0;
}