Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2005-06-02 11:22:00


Deane Yang wrote:
> Andy Little wrote:
>
>>
>> eg to find the point 1/3 rd way from the start of line(A , B) one could
>> calculate 2/3 *A +1/3 * B.
>>
>
> I think it is more natural to compute this as
>
> A + (1/3)*(B - A),
>
> where A and B are points and B - A is a vector. So you're really still
> just adding a vector to a point to get a new point. There is never a
> need to add or rescale points.
>

Now, to contradict myself, it is useful to rescale and add points in at
least one circumstance: when you want the "center of mass" or the
"average" of a set of points A1,..., An. In principle, you can do it as

B + [(A1-B) + .... + (An - B)]/n

but that's a lot of extra subtractions.

If I needed this (or a weighted average), I would probably encapsulate
it in a weighted average function (which would internally rescale and
add the points) and still disallow rescaling and adding points in my
library interface.

But I guess I now see why someone might just find it more convenient to
allow rescaling and adding points.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk