From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-04-27 08:37:33
>From: "David Abrahams" <dave_at_[hidden]>
> These are my (only slightly informed) opinions. I've heard Walter
> Brown talk about angle in this context, which was a big influence.
> Terje Slettebø <tslettebo_at_[hidden]> writes:
> > Regarding this angle dimension, should it be treated like the other
> > SI-dimensions? That is, say that you represent an SI quantity/unit
> > with an integer vector giving the exponents:
> > template<int kg,int m,int s,int A,int K,int mol,int cd,int angle>
> > class quantity;
> > If you multiply two quantities, you multiply the value and add the
> > exponents, so quantity<0,1,0,0,0,0,0,0>(10) *
> > = quantity<0,2,0,0,0,0,0,0>(100) (m * m = m^2)
> > Would this hold for angle, as well?
> Yes. Angle is a dimensionless scalar (length/length). All its
> exponents are zero.
Yes, Renej (in the posting I replied to) also pointed out that angle is a
dimensionless quantity. However, in their real-life experience, they found
it useful not to have it dimensionless, but instead having it as an
additional dimension, to be able to distinguish things like velocity and
angular velocity. It was in this context that I wondered how angle - as a
dimension - should be treated.
> > That is, does it make sense to say angle * angle = angle^2?
> Probably not, but only because angle * angle doesn't make much
> sense. Does that ever come up in real life?
If it's a dimensionless quantity, it wouldn't matter (all exponents would
still be zero). However, as a dimension, it would give angle^2. That's what
I wondered about.
> > I understand that e.g. angle/s (angular velocity) makes sense, but
> > should a library allow any combination with angle and the other
> > dimensions?
> Not arbitrarily:
I meant - should it allow the same combinations as the other dimensions are
allowed. That is (simplified, using only one dimension):
quantity<d1> * quantity<d2> = quantity<d1+d2>
quantity<d1> / quantity<d2> = quantity<d1-d2>
quantity<d> + quantity<d> = quantity<d>
quantity<d> - quantity<d> = quantity<d>
> angle(pi/2) / mass(40); // OK
> angle(pi/2) + mass(40); // error
Let's again cast it in the quantity<> example template I gave in the last
posting, to examine it. Let's say that the angle is expressed in radians. We
template<int kg,int m,int s,int A,int K,int mol,int cd,int rad>
typedef quantity<1,0,0,0,0,0,0,0> mass;
typedef quantity<0,0,0,0,0,0,0,1> angle;
angle(pi/2) * mass(40) = quantity<1,0,0,0,0,0,0,1>(pi/2*40) (rad * kg)
angle(pi/2) + mass(40)
The last one will be an error, as you said.
I'm guessing that the answer to my question is, yes, angle, when expressed
as a dimension, may be treated like the other dimensions.
There's also a question of what then if someone would like to add a money
dimension, to avoid having money be interchangeable with dimensionless
quantities. However, in this case, multiplying currencies with each other
really doesn't make any sense (e.g. USD(10)*USD(10) = USD^2?), which _would_
be allowed, if it used the same framework as above. Therefore, maybe money
is better treated in a different way, than with an exponent.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk