Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2007-02-10 20:29:00

Michael Marcin wrote:
> Matthias Schabel wrote:
>> Hi Michael,
>>> When working in 3d simulations it is necessary to transform vectors to
>>> different spaces. Bugs sometimes crop up when, for instance, adding a
>>> object space vector to a world space vector or adding a vector from
>>> object a's object space to one from object b's object space. It would
>>> be nice to catch such inconsistencies at compile-time. I have a
>>> feeling
>>> a units-like library would be able to handle this but I have no
>>> idea how
>>> it would work.
>> Here are two ways to do it, with the quantity wrapping the vector or the
>> vector containing quantities:
>> <snip>
> That's pretty cool and would likely catch many of the problems. The
> other error cases seem harder to detect at compile time. At least for
> my purposes there is only one world space but there can be an arbitrary
> number of object spaces. In addition it can be difficult to define
> correct conversions between spaces.

If you think about it, you begin to realize that in *all* code involving
arithmetic calculations (not just in physics or finance), you should
wrap virtually every double with a type and define allowable operations
using those types. This would catch a lot of errors at compile time.

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