
Boost : 
From: Janek Kozicki (janek_listy_at_[hidden])
Date: 20060615 17:40:40
Geoffrey Irving said: (by the date of Thu, 15 Jun 2006 10:23:24 0700)
> On Thu, Jun 15, 2006 at 07:11:23PM +0200, Janek Kozicki wrote:
> > 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 componentwise 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>.
You are absolutely right, I forgot about this one when I was talking
about quaternions. So it means that quaternions will be implementad as
separate class. Though it is possible that quaternion will use vector<4>
inside as a backend to store data...
> > 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.
IMHO it's a good solution. Such conversion would not be used anyway.
Also the documentation must explicitly state that q*v is actually a
conjugation.
In fact when I started working with yade, and had some problems. One of
the questions I asked myself was  what actually q*v is doing  does it
perform rotation (full conjugation)? Or maybe it's just multiplication?
I had to check that in the source, because I was using third party math
library, not a one written by me.
 Janek Kozicki 
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk