boost/units - converting forces (lbf->N)
To see if I understand the library, I want to create metric and imperial systems without using Boost Units predefined systems*. Conversions between lengths are going well. Conversion between forces are going well until pounds-force to newtons; line 182 in the link. What am I doing wrong when lbf will not convert to newtons? Here is my code: https://coliru.stacked-crooked.com/a/f5f80d39fbdf8013 Any help is appreciated. * //imperial namespace boost {namespace units { namespace us {}}}//sinamespace boost { namespace units { namespace si {}}}
On Sat, 1 Dec 2018 at 15:26, Matt Vinson via Boost-users < boost-users@lists.boost.org> wrote:
To see if I understand the library, I want to create metric and imperial systems without using Boost Units predefined systems*. Conversions between lengths are going well. Conversion between forces are going well until pounds-force to newtons; line 182 in the link. What am I doing wrong when lbf will not convert to newtons?
Gravity is not your friend [and gets in the way of what you want to do], you're not doing anything wrong [C++-wise], but you're converting hamburgers to cheeseburgers [for free], they don't convert.
From Wikipedia (https://en.wikipedia.org/wiki/Pound_(force)):
The pound-force is equal to the gravitational force exerted on a mass https://en.wikipedia.org/wiki/Mass of one avoirdupois pound https://en.wikipedia.org/wiki/Pound_(mass)#Avoirdupois_pound on the surface of Earth https://en.wikipedia.org/wiki/Earth. Since the 18th century, the unit has been used in low-precision measurements, for which small changes in Earth's gravity https://en.wikipedia.org/wiki/Gravity_of_Earth (which varies from place to place by up to half a percent) can safely be neglected.[4] https://en.wikipedia.org/wiki/Pound_(force)#cite_note-4 The 20th century, however, brought the need for a more precise definition. A standardized value for acceleration due to gravity was therefore needed. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
Thanks for response....Yes, yes, yes. I get that. I am having trouble understanding the library; not force. (Same as last time)
I guess I thought the library was magically accounting for gravity which is an error.
Updated:https://coliru.stacked-crooked.com/a/d256de6c16bdb08f
Thank you,
On Saturday, December 1, 2018, 9:10:38 AM CST, degski
From Wikipedia (https://en.wikipedia.org/wiki/Pound_(force)): The pound-force is equal to the gravitational force exerted on a mass of one avoirdupois pound on the surface of Earth. Since the 18th century, the unit has been used in low-precision measurements, for which small changes in Earth's gravity (which varies from place to place by up to half a percent) can safely be neglected.[4]
The 20th century, however, brought the need for a more precise definition. A standardized value for acceleration due to gravity was therefore needed. degski -- “If something cannot go on forever, it will stop" - Herbert Stein
This has errors still (lbf->N: 0.453592, N->lb: 0.183719) and I am addressing them...
On Saturday, December 1, 2018, 1:03:41 PM CST, Matt Vinson
From Wikipedia (https://en.wikipedia.org/wiki/Pound_(force)): The pound-force is equal to the gravitational force exerted on a mass of one avoirdupois pound on the surface of Earth. Since the 18th century, the unit has been used in low-precision measurements, for which small changes in Earth's gravity (which varies from place to place by up to half a percent) can safely be neglected.[4]
The 20th century, however, brought the need for a more precise definition. A standardized value for acceleration due to gravity was therefore needed. degski -- “If something cannot go on forever, it will stop" - Herbert Stein
AMDG On 12/01/2018 06:25 AM, Matt Vinson via Boost-users wrote:
To see if I understand the library, I want to create metric and imperial systems without using Boost Units predefined systems*. Conversions between lengths are going well. Conversion between forces are going well until pounds-force to newtons; line 182 in the link. What am I doing wrong when lbf will not convert to newtons?
There are a few problems. - BOOST_UNITS_DEFAULT_CONVERSION takes a unit (not a base unit) as its second argument. - You are defining both a kilogram_base_unit and a kilo_gram_base_unit. Either one will work, but you need to be consistent. You're defining the conversion in terms of kilo_gram_base_unit, but metric::system uses kilogram_base_unit. - The definition of a composite conversion for force is not needed and will be ignored. - metric and imperial have separate definitions of second_base_unit with no conversion between them. - lbf is not the same as (lbm in s^-2)
Here is my code: https://coliru.stacked-crooked.com/a/f5f80d39fbdf8013 Any help is appreciated.
* //imperial namespace boost {namespace units { namespace us {}}}//sinamespace boost { namespace units { namespace si {}}}
In Christ, Steven Watanabe
participants (3)
-
degski
-
Matt Vinson
-
Steven Watanabe