RE: [boost] Physical Quantities revisited
by Paul A. Bristow other posts by this author
Oct 11 2003 3:57PM messages near this date
[boost] Re: Physical Quantities revisited
|
RE: [boost] Physical Quantities revisited
I hate to be negative about your proposal (unlike many Boosters who seem to take
great delight in shooting/shouting anything down) but having glanced at the code
examples, I really don't think that this is the right way to go. I still think
that everything should be held internally in SI units - now that double has
enough range to cover almost everyones needs. I'm worried about conversion
loss - your first example warns of the danger. And I am worried about the
expansion to other all the types of units - many are unecessary (feet even!) but
widely used.
But we definitely still need a good system for Quantity units etc.
Paul
Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
mailto:pbristow@[...].com
| -----Original Message-----
| From: boost-bounces@[...].org
| [mailto:boost-bounces@[...].org]On Behalf Of Andy Little
| Sent: Friday, October 03, 2003 4:55 PM
| To: boost@[...].org
| Subject: [boost] Physical Quantities revisited
|
|
| Hi, I am a Newbie to Boost :-)
|
| I am currently working on an upgrade to a
| point-and-click small wind turbine rotor blade design app,
| which involves various physics.
| The original did its math in terms of inbuilt types ,
| but significant time is spent looking up (say)
| whether a length is in metres or millimetres
| or an angle in degrees or radians.
| I have also had requests from users for ability to work
| in (say) feet and inches etc rather than s.i. units.
|
| I have had a look at various physical quantities libraries
| including the "quantities" library at boost,
| and SIunits at
| http://www.fnal.gov/docs/working-groups/fpcltf/Pkg/SIunits/doc/0SIunits.html
|
| but they have an odd syntax.
|
| ie both do something like:
|
| length mylength = 20 * metres(); // here length is a type
|
| whereas what would seem to be more useful would be:
|
| metres myLength(20); // here metres is the type
| //*1 see footnote on explicit ctor
|
| The critical difference here is that the type is the
| unit of dimension, rather than the dimension itself.
| As a programmer if I want to know the units
| of a variable they are encoded in the type
| and if I can't decipher them I can do a conversion:
|
| metres mylength = metres(length_with_unknown_units);
| // ok... whatever units length_with_unknown_units was ,
| // mylength is its value in metres.
|
| I have spent some time creating a physical_quantities class template,
| with this approach, and have put the source code and
| a demo programme (and sample output) on my web site at:
| http://www.servocomm.freeserve.co.uk/Cpp/physical_quantity/index.html
|
| I would be interested to hear any views
| as to whether this approach is worth pursuing, or suggestions or
| improvements.
| ( Alternatively there may be a library that does this that I havent found
| ... ? )
|
| note: I have tried to answer some obvious questions and criticisms
| in the Potential FAQ on the page.
|
| ---
| *1 / this example is actually an error if coded as:
|
| metres myLength =1;
|
| in my version of physical_quantities
| because it violates dimensional analysis.
|
|
|
| _______________________________________________
| Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
|
|
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Jan Langer
Andy Little
Deane Yang
Paul A. Bristow
Phil Richards
Rene Jager
Deane Yang
Phil Richards
Andy Little
Deane Yang
Brock Peabody
Paul A. Bristow
Andy Little
Andy Little
Matthias Troyer
Paul A. Bristow
Ross MacGregor
Deane Yang
Paul A. Bristow
Deane Yang
Paul A. Bristow
Paul A. Bristow
David Abrahams
Jonathan de Halleux
Philip Miller
Deane Yang
Paul A. Bristow
Paul A. Bristow
David Abrahams
|