Boost logo

Boost :

From: Andreas Harnack (ah.boost.04_at_[hidden])
Date: 2007-03-09 12:47:16


Matthias Schabel schrieb:
[Snip]
> How do we convert 32 degrees Fahrenheit to Kelvin?
[Snip]
> Absolute temperature (K) = (Absolute temperature (F) - 32)*5/9 +273.15
>
> However, if we're talking about temperature differences (vectors),
> then the correct expression is
>
> Temperature difference (K) = Temperature difference (F)*5/9
[Snip]

Hi Matthias,

I had a similar problem to distinguish between coordinate
systems starting to count at one and those starting to count at
zero (which is the standard case). Here is my (very simple)
solution:

template<class T, unsigned int D> class coord
{
         // a coordinate is a dimension starting to count at 1
                 T v;
         public:
                 coord(euclid::dim<T, D> d) : v(d()+1) {}
                 coord(T v0): v( v0>0 ? v0 : 1 ) {}
                 coord(const coord &v0) : v(v0.v) {}
                 coord& operator=(const coord &v0)
                         { v = v0.v; return *this; }
                 euclid::dim<T, D> operator ()()
                         { return euclid::dim<T, D>(v-1); }
};

It's intentionally that you can't do anything with a non
standard coordinate but transform it into the standard
representation (i.e. a dimension). I just couldn't think of any
other meaningful operation.

Both coordinate systems are technically different vector spaces.
Both describe the same points in space, but the vector
operations lead to different results when interpreted back into
the real world. It seems, only the standard representation can
be interpreted in a meaningful way.

I think it's the same thing with different temperature units.
Each unit defines its own (in this case one-dimensional) vector
space. You can add Kelvin to Kelvin and Celsius to Celsius, but
you can't mix them. The corresponding results are either in
Kelvin or in Celsius respectively and are mathematically two
different things. The same applies to differences. That they
have the same physical interpretation is rather a coincident.

293.15 Kelvin represent the same temperature as 20 degrees
Celsius, but doubling both will lead to very different results.
It's up to the user to decide, what 'doubling a temperatures' is
supposed to mean in the real world and pick a vector space, i.e.
a unit, accordingly; be it Kelvin, Celsius, Fahrenheit or
something entirely different. So I'd stick to offer a
transformation between absolute temperatures.

Differences are meaningful only within a particular vector
space. Theoretically you could introduce a notation of a norm,
that would be origin invariant but depending on the scale. So
Kelvin and Celsius would have the same norm while the norm of
Fahrenheit needs to be scaled by 5/9. This, however, is probably
much to much hassle.

Greetings,
Andreas


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk