*.h-----------------------------------------------------
namespace dimensional_analysis {
typedef boost::units::length_base_dimension::dimension_type length_dimension;
typedef boost::units::mass_base_dimension::dimension_type mass_dimension;
typedef boost::units::make_system<boost::units::us::inch_base_unit,boost::units::us::pound_base_unit>::type ip_system;
namespace lineal_force {
typedef boost::mpl::divides<boost::units::force_dimension,boost::units::length_dimension>::type lineal_force_dimension;
namespace imperial {
////////////////
////lb/in, right?
////boost::units::force_dimension = pound
////boost::units::length_dimension = in
////////////////
typedef boost::units::unit<lineal_force_dimension,lengths::ip_system> lineal_force_unit;
}
namespace si {
////////////////
////N/m, right?
////boost::units::force_dimension = newton
////boost::units::length_dimension = meter
////////////////
typedef boost::units::unit<lineal_force_dimension,boost::units::si::system> lineal_force_unit;
}
}//lineal_force
}//dimensional_analysis
*.cpp-----------------------------------------------------
//Imperial lb/in to SI N/m
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
dimensional_analysis::lineal_force::imperial::lineal_force_unit,
dimensional_analysis::lineal_force::si::lineal_force_unit,
double,
175.1268369864); // exact conversion
BOOST_UNITS_DEFAULT_CONVERSION(
dimensional_analysis::lineal_force::imperial::lineal_force_unit,
dimensional_analysis::lineal_force::si::lineal_force_unit);
//SI N/m to Imperial lb/in
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
dimensional_analysis::lineal_force::si::lineal_force_unit,
dimensional_analysis::lineal_force::imperial::lineal_force_unit,
double,
0.1837185501); // exact conversion
BOOST_UNITS_DEFAULT_CONVERSION(
dimensional_analysis::lineal_force::si::lineal_force_unit,
dimensional_analysis::lineal_force::imperial::lineal_force_unit);
//Imperial to SI. This should convert lb/in to N/m and return 175.1268369864 (N/m)
//But it does not. Its converting lb (mass) to Kg (mass), 0.454
const auto t2 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::si::lineal_force_unit>>(
1.0 * dimensional_analysis::lineal_force::imperial::lineal_force_unit::unit_type());
//Again, Imperial to SI. This should convert lb/in to N/m and return 175.1268369864 (N/m)
//But it does not. It returns lb (mass) to Kg (mass)
const auto t3 = boost::units::conversion_factor(
dimensional_analysis::lineal_force::imperial::lineal_force_unit::unit_type(),
dimensional_analysis::lineal_force::si::lineal_force_unit::unit_type());
//SI to Imperial. This should convert N/m to lb/in and return 0.1837185501 (lb/in)
//But it does not. Its converting Kg (mass) to lb (mass), 2.205
const auto t1 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::imperial::lineal_force_unit>>(
1.0 * dimensional_analysis::lineal_force::si::lineal_force_unit::unit_type());
//So, I don’t know why the library is converting mass; I’ve tuned it to use boost::units::force_dimension/boost::units::length_dimension
//I am doing something wrong where the library is not using force/length.
//Below does work, mainly.
//This is convert Si to SI and return value of 1.0 is correct.
const auto t4 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::si::lineal_force_unit>>(
1.0 * boost::units::si::newton / boost::units::si::meter);
//This convert lb/in to SI and return value is 175.1268369864 is correct.
const auto t5 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::si::lineal_force_unit>>(
1.0 * boost::units::us::pound_force_base_unit::unit_type() / boost::units::us::inch_base_unit::unit_type());
//This converts lb/in to lb/in and return value is of 1.0 is correct.
const auto t6 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::imperial::lineal_force_unit>>(
1.0 * boost::units::us::pound_force_base_unit::unit_type() / boost::units::us::inch_base_unit::unit_type());
//This is 2.205 and not correct.
//It’s not
converting SI-force/length to Imperial-force/length
//Its converting Kg (mass) to lb (mass), 2.205
const auto t7 = static_cast<boost::units::quantity<dimensional_analysis::lineal_force::imperial::lineal_force_unit>>(
1.0 * boost::units::si::newton / boost::units::si::meter);
//What have I done wrong?