[boost] Physical Quantities revisited
by Andy Little other posts by this author
Oct 3 2003 3:55PM messages near this date
[boost] Re: Any interrest for zip/bzip2 iostreams ?
|
[boost] Re: 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
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
|