
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Phil Richards Sent: Wednesday, August 23, 2006 8:58 AM To: boost@lists.boost.org Subject: Re: [boost] Boost Units library preview
On 2006-08-23, Matthias Troyer <troyer@itp.phys.ethz.ch> wrote:
- Nm would be a "dimension"
Not really. It is the unit.
Correct. A newton is a derived unit composed of base units, specifically kilogram, meter, and second. Meter is of course a base unit.
The dimension is: MASS * LENGTH^2 * TIME^2
Also correct. Every unit, whether a base unit or derived, has a corresponding dimension.
- 1 Nm would be a "quantity"
No. This is a measure. It has a specific unit and a specific value. Here's an example of a quantity. The distance from here->| |<-to here is a quantity with a dimension of length. You don't know what its value is exactly but you do know that it has a value and can be measured. Until you actually measure this length with a particular unit does the "quantity" become a "measure". Converting a measure into a quantity is essentially the same as stripping away the unit but keeping the dimension. Does that make sense?
- a torque measured in Nm or an energy measured in Nm would be two distinct units
Dimensions and units are C++ types. They have no "value" in the conventional sense.
- 1 Nm as torque, 1 Nm as energy or 1 J as energy would be three distinct measures
I think as far as a dimensionality checking goes, they are all the same. As far as a units checking goes, Nm and J *could* be distinguished. It's an interesting question as to what, exactly, "energy" and "torque" are once you try to separate away the dimensionality and units bits... :-)
Yep, if the units are the same and the value is the same then they are (or should be) considered the same measure. I think it should be left up to users to interpret these measures and how they are used. Eric.

On Aug 24, 2006, at 1:23 AM, Eric Lemings wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Phil Richards Sent: Wednesday, August 23, 2006 8:58 AM To: boost@lists.boost.org Subject: Re: [boost] Boost Units library preview
On 2006-08-23, Matthias Troyer <troyer@itp.phys.ethz.ch> wrote:
- Nm would be a "dimension"
Not really. It is the unit.
Correct. A newton is a derived unit composed of base units, specifically kilogram, meter, and second. Meter is of course a base unit.
The dimension is: MASS * LENGTH^2 * TIME^2
Also correct. Every unit, whether a base unit or derived, has a corresponding dimension.
- 1 Nm would be a "quantity"
No. This is a measure. It has a specific unit and a specific value.
Here's an example of a quantity. The distance from here->| |<-to here is a quantity with a dimension of length. You don't know what its value is exactly but you do know that it has a value and can be measured. Until you actually measure this length with a particular unit does the "quantity" become a "measure". Converting a measure into a quantity is essentially the same as stripping away the unit but keeping the dimension.
OK, but then a quantity can never be represented in the computer, since to assign a numerical value to above distance one needs a unit.
- a torque measured in Nm or an energy measured in Nm would be two distinct units
Dimensions and units are C++ types. They have no "value" in the conventional sense.
OK, so would the type of "Nm torque" or "Nm energy" be the same or different?
- 1 Nm as torque, 1 Nm as energy or 1 J as energy would be three distinct measures
I think as far as a dimensionality checking goes, they are all the same. As far as a units checking goes, Nm and J *could* be distinguished. It's an interesting question as to what, exactly, "energy" and "torque" are once you try to separate away the dimensionality and units bits... :-)
Yep, if the units are the same and the value is the same then they are (or should be) considered the same measure. I think it should be left up to users to interpret these measures and how they are used.
Well, as a physicist for me 1 J and 1 Nm are the same. I would reject and never use a library that forces me to distinguish physically identical quantities just because I use a different name for the unit. Matthias

Matthias Troyer said: (by the date of Thu, 24 Aug 2006 13:17:09 +0900)
Well, as a physicist for me 1 J and 1 Nm are the same. I would reject and never use a library that forces me to distinguish physically identical quantities just because I use a different name for the unit.
fully agree, distinguishing between torque and energy is artificial. And just look how much complications it adds to the library! Whole new concept of anonymous_quantity, serialization (outputting units values) burden, etc... Displaying a unit using correct unit should be left up for the user - he chooses what name he wants displayed. The library could only take care to correctly convert the value for output requested so that it matches required unit - eg. passed as a string: "kNm","Nm","J","kWh" or "kg m^2 s^-2" -- Janek Kozicki |

Janek Kozicki said: (by the date of Thu, 24 Aug 2006 11:12:20 +0200)
Matthias Troyer said: (by the date of Thu, 24 Aug 2006 13:17:09 +0900)
Displaying a unit using correct unit should be left up for the user - he chooses what name he wants displayed. The library could only take care to correctly convert the value for output requested so that it matches required unit - eg. passed as a string: "kNm","Nm","J","kWh" or "kg m^2 s^-2"
sorry, in fact it is enough if the library makes it possible to do such conversion before the user outputs his value. This can be as simple as declaring a temporary of desired unit, assigning and then printing it. So no parsing of strings "kWh" is necessary inside the libary. That's the 'minimalism' route taken by Eric. This solution is good for me too. Adheres to ockham's razor ;) -- Janek Kozicki |

"Janek Kozicki" <janek_listy@wp.pl> wrote in message news:20060824111220.55aa94f6@absurd...
Matthias Troyer said: (by the date of Thu, 24 Aug 2006 13:17:09 +0900)
Well, as a physicist for me 1 J and 1 Nm are the same. I would reject and never use a library that forces me to distinguish physically identical quantities just because I use a different name for the unit.
fully agree, distinguishing between torque and energy is artificial. And just look how much complications it adds to the library! Whole new concept of anonymous_quantity, serialization (outputting units values) burden, etc...
Displaying a unit using correct unit should be left up for the user - he chooses what name he wants displayed. The library could only take care to correctly convert the value for output requested so that it matches required unit - eg. passed as a string: "kNm","Nm","J","kWh" or "kg m^2 s^-2"
The output of units in Quan is modular, so you don't need to include it if you don't want to You can also work exclusively with anonymous quantities if you prefer. However I believe that the easy ability to get some convenient output feedback in quick tests and examples lowers the entry barrier. The ouput of units is after all a concise description of a quantity. FWIW you can output the units in the default form if you prefer: #include <quan/out/torque.hpp> #include <quan/out/energy.hpp> int main() { quan::torque::N_m torque(1); quan::energy::J energy(1); std::cout << "energy value = " << energy << ", units = " << energy.get_unit() << '\n'; std::cout << "torque value = " << torque << ", units = " << torque.get_unit() << '\n'; } outout: energy value = 1 J, units = kg.m+2.s-2 torque value = 1 N.m, units = kg.m+2.s-2 (BTW note the get_unit function is changed lately from previous versions where IIRC it was just q.units()) regards Andy Little
participants (4)
-
Andy Little
-
Eric Lemings
-
Janek Kozicki
-
Matthias Troyer