boost::units - converting from one derived_dimension to another across systems (imperial to metric)
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
*.h--------------------------------------------------------------------------------
namespace dimensional_analysis {
namespace lineal_force { //lb/in
typedef boost::units::derived_dimension<
boost::units::us::pound_force_base_unit, 1,
boost::units::us::inch_base_unit, -1
>::type lb_per_inch_dimension;
typedef boost::units::unit<
lb_per_inch_dimension,
dimensional_analysis::lengths::ip_system
> lb_per_inch_unit;
typedef boost::units::quantity
AMDG On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote:
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between them.
*.h-------------------------------------------------------------------------------- namespace dimensional_analysis { namespace lineal_force { //lb/in typedef boost::units::derived_dimension< boost::units::us::pound_force_base_unit, 1, boost::units::us::inch_base_unit, -1 >::type lb_per_inch_dimension;
units are not dimensions. You can't use derived_dimension with base_units.
<snip>
In Christ, Steven Watanabe
On Nov 15, 2018, at 8:18 AM, Steven Watanabe via Boost-users
wrote: AMDG
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote: I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between them.
*.h-------------------------------------------------------------------------------- namespace dimensional_analysis { namespace lineal_force { //lb/in typedef boost::units::derived_dimension< boost::units::us::pound_force_base_unit, 1, boost::units::us::inch_base_unit, -1 >::type lb_per_inch_dimension;
units are not dimensions. You can't use derived_dimension with base_units.
<snip>
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
There is technically a kilogram force unit, kg-f or kilopond. I don’t know if that’s in Units though. Damien
On Thu, Nov 15, 2018 at 10:29 AM Damien Hocking via Boost-users
On Nov 15, 2018, at 8:18 AM, Steven Watanabe via Boost-users
wrote: AMDG
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote: I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between them.
*.h-------------------------------------------------------------------------------- namespace dimensional_analysis { namespace lineal_force { //lb/in typedef boost::units::derived_dimension< boost::units::us::pound_force_base_unit, 1, boost::units::us::inch_base_unit, -1 >::type lb_per_inch_dimension;
units are not dimensions. You can't use derived_dimension with base_units.
<snip>
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
There is technically a kilogram force unit, kg-f or kilopond. I don’t know if that’s in Units though.
That, or, if memory serves, you need to factor out gravitational, or whatever other force, is being masked by the lb. Cheers...
Damien _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 15/11/2018 15:18, Steven Watanabe via Boost-users wrote:
AMDG
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote:
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between them.
lb·f (foot-pounds) is force; lb is mass. The code in question is using pounds force, so won't be convertible to inches as you say, just wanted to correct the terminology. Regards, Roger
On Thu, Nov 15, 2018 at 11:11 AM Roger Leigh via Boost-users
On 15/11/2018 15:18, Steven Watanabe via Boost-users wrote:
AMDG
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote:
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between them.
lb·f (foot-pounds) is force; lb is mass.
No, lb-f is a unit of Torque. lb is a unit of Force.
The code in question is using pounds force, so won't be convertible to inches as you say, just wanted to correct the terminology.
Regards, Roger
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 15.11.2018 17:27, Michael Powell via Boost-users wrote:
On Thu, Nov 15, 2018 at 11:11 AM Roger Leigh via Boost-users
wrote: On 15/11/2018 15:18, Steven Watanabe via Boost-users wrote:
AMDG
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #: It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote: them. lb·f (foot-pounds) is force; lb is mass. No, lb-f is a unit of Torque. lb is a unit of Force.
Hmm, that pound is primarily unit of force is a news to me. The following is from the UK's Weights and Measures Act 1963: "Theyard https://en.wikipedia.org/wiki/Yardor themetre https://en.wikipedia.org/wiki/Metreshall be the unit of measurement oflength https://en.wikipedia.org/wiki/Lengthand the pound or thekilogram https://en.wikipedia.org/wiki/Kilogramshall be the unit of measurement of mass by reference to which any measurement involving a measurement of length ormass https://en.wikipedia.org/wiki/Massshall be made in the United Kingdom; and- (a) the yard shall be 0.9144 metre exactly; (b) the pound shall be0.45359237kilogram exactly." To my knowledge, the US still adhere to 1894's update to Mendenhall Order which defined that there shall be 2.20462234pounds to a kilogram. On the other hand, lbf is often used to denote "pound force" unit, with 1 lbf being approximately 4.448N or 0.454 kp. So Boost.Units should then not be used for cooking recipes as the conversions from pound based to gram based quantities would only work on Earth? Cheers, Leon
On 11/16/18 4:57 AM, Leon Mlakar via Boost-users wrote:
On 15.11.2018 17:27, Michael Powell via Boost-users wrote:
On Thu, Nov 15, 2018 at 11:11 AM Roger Leigh via Boost-users
wrote: On 15/11/2018 15:18, Steven Watanabe via Boost-users wrote:
AMDG
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #: It's not going to work. lb is a unit of force, but kg is a unit of mass. They are not compatible and there is no conversion between
On 11/14/2018 05:04 AM, Matt Vinson via Boost-users wrote: them. lb·f (foot-pounds) is force; lb is mass. No, lb-f is a unit of Torque. lb is a unit of Force.
Hmm, that pound is primarily unit of force is a news to me. The following is from the UK's Weights and Measures Act 1963:
"The yard https://en.wikipedia.org/wiki/Yard or the metre https://en.wikipedia.org/wiki/Metre shall be the unit of measurement of length https://en.wikipedia.org/wiki/Length and the pound or the kilogram https://en.wikipedia.org/wiki/Kilogram shall be the unit of measurement of mass by reference to which any measurement involving a measurement of length or mass https://en.wikipedia.org/wiki/Mass shall be made in the United Kingdom; and- (a) the yard shall be 0.9144 metre exactly; (b) the pound shall be 0.45359237 kilogram exactly."
To my knowledge, the US still adhere to 1894's update to Mendenhall Order which defined that there shall be 2.20462234pounds to a kilogram.
On the other hand, lbf is often used to denote "pound force" unit, with 1 lbf being approximately 4.448N or 0.454 kp.
So Boost.Units should then not be used for cooking recipes as the conversions from pound based to gram based quantities would only work on Earth?
Cheers,
Leon
In Common, and legal, usage, the Pound represents both a mass unit and a Force unit, a pound of food is mass, in a pound/sq-in it is a force. In scientific uses, one shouldn't use the base pound unless it is totally obvious which one is being used, but instead you use the units of pound-force or pound-mass, lbf (not lb-f) vs lbm, Boost, since it can't know which one is being used, as the context will never be obvious to the compiler, probably should not have a raw lb unit, but only lbf and lbm. -- Richard Damon
Hi list,
I am having trouble converting from one derived_dimension to another across systems (imperial to metric). I'd like to convert, say, lb/in to, say, kg/m. I thought I would do the following but get a compiler error #:
*.h-------------------------------------------------------------------------------- namespace dimensional_analysis { namespace lineal_force { //lb/in typedef boost::units::derived_dimension< boost::units::us::pound_force_base_unit, 1, boost::units::us::inch_base_unit, -1 >::type lb_per_inch_dimension; typedef boost::units::unit< lb_per_inch_dimension, dimensional_analysis::lengths::ip_system > lb_per_inch_unit; typedef boost::units::quantity
lb_per_inch_quantity; BOOST_UNITS_STATIC_CONSTANT(lbpin, lb_per_inch_quantity); //kg/m typedef boost::units::derived_dimension< boost::units::si::kilogram_base_unit, 1, boost::units::si::meter_base_unit, -1 >::type kg_per_meter_dimension; typedef boost::units::unit< kg_per_meter_dimension, boost::units::si::system > kg_per_meter_unit; typedef boost::units::quantity kg_per_meter_unit_quantity; BOOST_UNITS_STATIC_CONSTANT(kgpm, kg_per_meter_unit_quantity); }//lineal_force }//dimensional_analysis *.cp ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //Do I need these? BOOST_UNITS_DEFINE_CONVERSION_FACTOR(dimensional_analysis::lineal_force::kg_per_meter_unit, dimensional_analysis::lineal_force::lb_per_inch_unit, double, 0.0559974); // exact conversion BOOST_UNITS_DEFAULT_CONVERSION(dimensional_analysis::lineal_force::kg_per_meter_unit, dimensional_analysis::lineal_force::lb_per_inch_unit);
//This does not compile# const auto conv_factor_try0 = conversion_factor(dimensional_analysis::lineal_force::kg_per_meter_unit::unit_type(), dimensional_analysis::lineal_force::lb_per_inch_unit::unit_type());
# *\boost_1_68_0\boost\units\detail\conversion_impl.hpp(340): error C2672: 'conversion_factor': no matching overloaded function found (compiling source file...*.cpp)
Any help is appreciated
I opened a PR (https://github.com/boostorg/units/pull/32) to address
such a situation;
the following code
```cpp
#include <iostream>
#include
participants (8)
-
Damien Hocking
-
Eisuke Kawashima
-
Leon Mlakar
-
Matt Vinson
-
Michael Powell
-
Richard Damon
-
Roger Leigh
-
Steven Watanabe