Boost logo

Boost :

From: Geoffrey Irving (irving_at_[hidden])
Date: 2006-06-15 13:23:24


On Thu, Jun 15, 2006 at 07:11:23PM +0200, Janek Kozicki wrote:
>
> Your arguments did not convince me at all, because they are out of place.
>
> Also - think about it - there is only one applicable definition of
> multiplication between vector<3> and vector<4> - and this definition
> will assume vector<4> to be quaternion which rotates vector<3>

I wish that were the case, but sadly, quaternion multiplication is
slightly ambiguous.

The problem is that the normal quaternion rotation is actually a
conjugation:

  rotated_v = q v q^-1

where v = (x,y,z) is canonically viewed as the quaternion (0,x,y,z).
rotated_v will come out looking like (0,rx,ry,rz), so we can drop the
zero and view it as a vector again.

This could be a problem if the conversion between vector<3> and
quaternion was an actual C++ conversion, since q * v could mean two
completely different things. I imagine most people handle this by
disallowing that conversion.

> Other definition for such multiplication doesn't exist, so there is no
> conflict with other math fields. It's specific just like cross product
> for vector<3>
>
> So still I think that quaternion can be a template specialization for
> unitless (dimensionless) vector<4>. Also we can add a
> typedef quaternion<double> vector<4,double>; // etc...

That's bad for the following simple reason. If you give people two
vector<4>'s and ask them to multiple them, they'll expect the answer
to either not exist or be component-wise multiplication. There's very
little chance they'll expect fancy quaternion multiplication.
Quaternions need a multiplication operator to be useful, so they can't
be the same as vector<4>.

Geoffrey


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