Hello Everybody,

I'm pretty much sure, that qmult (multiplication of two quaternions) returns 
totally wrong results.

>From the current source:

% a being the real part, b the first imaginary...
  [a1, b1, c1, d1] = quaternion (a);
  [a2, b2, c2, d2] = quaternion (b);

% the following calculations seem to be wrong
  ri = b1*c2 - c1*b2 + d1*a2 + a1*d2;
  rj = c1*a2 - a1*c2 + d1*b2 + b1*d2;
  rk = a1*b2 - b1*a2 + d1*c2 + c1*d2;
  rr = -(a1*a2 + b1*b2 + c1*c2) + d1*d2;

% further more the resulting quaternion does not start with the real part
  retval = quaternion (ri, rj, rk, rr);

Multiplying the real numbers (1,0,0,0)*(1,0,0,0) yields (0,0,0,-1) with this 
code, which I hope is wrong.


I propose the following fix (taken directly from the sourcecode of 
wikipedia, no further checks done, no testing):

[ar, ai, aj, ak] = quaternion (a);
[br, bi, bj, bk] = quaternion (b);

rr = ( ar * br - ai * bi - aj * bj - ak * bk);
ri = ( ar * bi + ai * br + aj * bk - ak * bj);
rj = ( ar * bj - ai * bk + aj * br + ak * bi);
rk = ( ar * bk + ai * bj - aj * bi + ak * br);

retval = quaternion(rr, ri, rj, rk);

I have not checked the other functions in pkg quaternion, but they might be 
wrong as well...

Best regards
Jan Hieronymus 


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to