From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-04-27 07:19:31
Still on the subject of a quantity library.
> > There is DEFINITELY a need for this - and in the C++ Standard Library,
> > but the relative merits of the two proposals mae so far are not yet
> > clear to me.
> > Perhaps we need more real user experience. (Or is the problem that the
> > MSVC compiler can't/couldn't handle the SIUnits code?)
> real user experience... you asked for it ;-)
> we use the int-based template approach for a couple of years now in
> our AGV controller software. We actually sometimes reach the stage that
> it works when succesfully compiled and linked. Since our control software
> is physics throughout (field of robotics), the type safety is very
> important. However, besides the basic SI units we also have 'angle'
> as a dimension which allows us to distinguish 'velocity' and 'angular
> velocity' for example. Hence, from out 'real user' experience (engineering
> point of view) it would be a necessity to add 'angle' as a dimension
> without breaking already defined quantities. Most (all?) units libraries
> already define 'angle' to be dimensionless, which is true in
> spoken, but pragmatically (engineering ;-) less handy.
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>
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,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? That is, does it make sense to say angle
* angle = angle^2? I understand that e.g. angle/s (angular velocity) makes
sense, but should a library allow any combination with angle and the other
How do you treat angle in your own library?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk