|
Boost : |
From: Ben FrantzDale (benfrantzdale_at_[hidden])
Date: 2007-01-16 11:53:29
On 1/15/07, Matthias Schabel <boost_at_[hidden]> wrote:
>
>
> > And quantity conversion should require explicit casting:
> >
> > quantity< double, SI::centigrade > q4;
> > quantity< double, SI::kelvin > q5;
> > q5 = quantity_cast< SI::kelvin >(q4);
>
> Of course, the centigrade<->kelvin issue opens a new can of worms
> since that conversion is affine, not linear. At present,
> this conversion is not implemented in the library. My preference
> would be to define a value_type that models a unit with offset that
> could be converted to linear value_types... Right now, the library
> allows implicit unit system conversions (as described above), and,
> with quantity_cast, would allow casting as well.
>
That difference between an affine space and a linear (vector) space is an
important one. The Boost date & time library makes the distinction:
http://www.boost.org/doc/html/date_time.html#date_time.domain_concepts
If this library made the vector/point distinction, temperature conversion
would be a non-issue. Something like:
dimensioned<int, SI::kelvin> k1(100*SI::kelvin), k2(200*SI::kelvin);
quantity<int, SI::kelvin> kdiff = k2 - k1;
quantity<int, SI::celsius> cdiff = difference; // Celsius and Kelvin
differences are really the same thing.
Ben
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk