boost::units - converting from one derived_dimension to another across systems (imperial to metric)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::units - converting from one derived_dimension to another across systems (imperial to metric)

Boost - Users mailing list
Thanks for input...
Ok, I have errors creating a 'lineal force unit'.

In our branch of engineering, we have kips****/ft, kips/in, lbs/foot, lbs/in, kN/meter, Kn/cm, KN/mm, N/meter, N/cm, N/mm, Metric Ton/meter, Metric Ton/cm, Metric Ton/mm, KiloGram/meter $, KiloGram/cm, KiloGram/mm, etc....
All these units* are loosing force divided by length.

After all the appreciated input in this thread, I thought I'd try this but it does not compile*** probably because force is "L M T^-2" and length is "L" which is not correct:
        //Lineal Force
        typedef boost::units::derived_dimension<
            boost::units::force_dimension, 1,
            boost::units::length_dimension, -1
        >::type lineal_force_dimension;

How can I use Boost.Units to convert one force/length to another force/length: say, lb/in to, say, kg/m?

*not Boost.Units**, the units in the engineering math equation
**A set of base units raised to rational exponents, e.g. m^1, kg^1, m^1/s^2.
*** ...\boost_1_68_0\boost\mpl\aux_\preprocessed\plain\less.hpp(20): error C2039: 'value': is not a member of 'boost::units::detail::dimension_list_tag'
****1000 lbs force = kips
***** Here is a table in Wiki about converting between lbs and kilogram.  Kilogram in Boost.Units is a mass not a force so I need to create a kilogram force and I did that when I converted "Forces" $ in another task...
">
$
.h
        struct metric_ton_base_unit : boost::units::base_unit<metric_ton_base_unit, boost::units::force_dimension, 7> { };
        typedef metric_ton_base_unit::unit_type metric_ton_unit;
        BOOST_UNITS_STATIC_CONSTANT(metric_ton, metric_ton_unit);
        typedef boost::units::quantity<metric_ton_unit> metric_ton_quantity;
        //
        typedef boost::units::make_scaled_unit<metric_ton_unit, boost::units::scale<10, boost::units::static_rational<-3>>>::type kg_force_unit;
        BOOST_UNITS_STATIC_CONSTANT(kg_force, kg_force_unit);
        typedef boost::units::quantity<kg_force_unit> kg_quantity;
.cpp
       BOOST_UNITS_DEFINE_CONVERSION_FACTOR(dimensional_analysis::force::metric_ton_base_unit, dimensional_analysis::force::newton_base_unit, double, 9806.65); // exact conversion
BOOST_UNITS_DEFAULT_CONVERSION(dimensional_analysis::force::metric_ton_base_unit, dimensional_analysis::force::newton_base_unit);%

$ lb/in to kg/m: Google: convert lb/in to kg/m


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

1542370857809blob.jpg (23K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: boost::units - converting from one derived_dimension to another across systems (imperial to metric)

Boost - Users mailing list
AMDG

On 11/16/2018 05:27 AM, Matt Vinson via Boost-users wrote:
> Thanks for input...Ok, I have errors creating a 'lineal force unit'.
> In our branch of engineering, we have kips****/ft, kips/in, lbs/foot, lbs/in, kN/meter, Kn/cm, KN/mm, N/meter, N/cm, N/mm, Metric Ton/meter, Metric Ton/cm, Metric Ton/mm, KiloGram/meter $, KiloGram/cm, KiloGram/mm, etc....All these units* are loosing force divided by length.
> After all the appreciated input in this thread, I thought I'd try this but it does not compile*** probably because force is "L M T^-2" and length is "L" which is not correct:        //Lineal Force
>         typedef boost::units::derived_dimension<
>             boost::units::force_dimension, 1,
>             boost::units::length_dimension, -1
>         >::type lineal_force_dimension;
>

derived_dimension works with the base_dimensions not a dimension list.
Use either:

boost::units::derived_dimension<
  boost::units::mass_base_dimension, 1,
  boost::units::time_base_dimension, -2>::type

or

boost::mpl::divides<
  boost::units::force_dimension,
  boost::units::length_dimension>::type

> How can I use Boost.Units to convert one force/length to another force/length: say, lb/in to, say, kg/m?
> *not Boost.Units**, the units in the engineering math equation**A set of base units raised to rational exponents, e.g. m^1, kg^1, m^1/s^2.
> *** ...\boost_1_68_0\boost\mpl\aux_\preprocessed\plain\less.hpp(20): error C2039: 'value': is not a member of 'boost::units::detail::dimension_list_tag'
> <snip>>

In Christ,
Steven Watanabe
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users