Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-01-08 19:15:04

Andy Little wrote:

>Documentation and link to a download, for my lib can be found here. :

Cool. I'll look into the library.

As far as I can see, there are several areas that a quantities library must
deal with. The basic concepts are:

Unit -- A type of value that has an associated property; the unit will have
a name and may also have an associated symbol;

Base Unit -- A unit whose type is orthogonal with other non-derived units;
it is used to derive other units - this is a closed set;

Base Set -- A set of base units that fully describe the problem domain
considered e.g. the SI base units form a base set

Derived Units -- A unit that is constructed from other units and can be
expressed in terms of the base units e.g. area, acceleration;

Derived Set -- The set of unit types that can be constructed from the base
set - this is an open set

Prefixes -- A set of powers that express the size magnitude of the value to
a base unit (e.g. micro; milli; tera; giga for base 10 and bit; byte; kibi;
tebi for binary). NOTE: these could (and should) be expressed within a
constants framework.

Unit System -- A system of units that consists of a base set and a derived

Ideally, prefixes should be expressed seperately, allowing for easy
conversion between types with different prefixes (cm -> km, etc.), e.g.:
   typedef unit::declare< unit::si::length, unit::prefix::mili > mm;

It should be possible to express base units as an orthogonal group of
dimensions in a unit system, e.g.:
   typedef unit::dimension< unit::system::si_units, 1 > length;
   typedef unit::declare< unit::si::length > meter; // no prefix

Derived units should be composable from base units:
   typedef unit::derived< unit::power< unit::si::length, 1 >, unit::power<
unit::si::time, -1 > >

I am not sure how you would then compose cm / hour, or prefix other derived
units within this system.

SI::mass (kilogram) is unusual, since it is prefixed -- the base unit is the
gram with an associated prefix. Also, units like hours (60 * 60 * second)
are somewhere between being a derived unit and a prefix (since it is a
multiple of the base unit).
   static const int hours = 60 * 60; // seconds : hour
   static const float kilo = 10e3;

The units system should allow something like:
   si::speed s = 7 * si::m / si::s;
   si::acceleration g = 9.2 * si::m / si::s_2; // si::s_2 = si::s * si::s
   // ...
   s *= g; // increase speed


Stay in touch with absent friends - get MSN Messenger

Boost list run by bdawes at, gregod at, cpdaniel at, john at