|
Boost : |
From: Deane Yang (deane_yang_at_[hidden])
Date: 2005-10-12 19:31:31
Andy Little wrote:
> You need + in the interface so users like me can write out the formulas as they
> see them written down.
>
...
> The fact that it can
>> be written in terms of vector addition is an implementation detail and
>> should be hidden from the interface.
>
> Nonsense. '+' should be part of the interface.
>
...
> If the goal is to write good code, then please dont cooerce me to do home-made
> rearrangements of standard formulas to hide +. Thats a source of errors if ever
> there was one ;-)
>
...
> It certainly wastes my time trying to find workarounds or rearranging perfectly
> good formulae.to use '-'. More work for anyone reading or reviewing the code
> too.
>
...
>
> Maybe it makes the programmer wonder why they didnt provide operator +.
>
In other words, you want to treat points as if they were vectors. But
you can do so by simply ignoring and not using the classes that
represent point quantities and simply using vector quantities for your
points and vectors alike.
On the other hand, if the library itself implements point quantities as
if they have the same properties as vector quantities, then nothing is
gained by defining point quantities as a different class from vector
quantities.
I have to say I have sympathy for your point of view. If you are
programming physical or geometric formulas from a reference, then it
will be given in terms of "+", so it would indeed take more work and
effort to onvert them correctly into formulas that only use barycentric
combinations and differences. I like going through this exercise and
consider it helpful in writing correct code, but I can see how many
programmers would consider it a complete waste of time.
I would encourage you to try it out; I claim that the new formulas are
often easier to understand than the traditional ones.
But if you really don't like it, just stick to vectors and ignore
everything in the library referring to affine spaces or point quantities.
I'd like a library that can handle both points of view.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk