home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
octa21eb.zip
/
octave
/
SCRIPTS.ZIP
/
scripts.fat
/
quatern
/
qmult.m
< prev
next >
Wrap
Text File
|
1999-04-29
|
584b
|
22 lines
function retval = qmult(a,b)
# function retval = qmult(a,b)
# multiply two quaterns
# [w,x,y,z] = w*i + x*j + y*k + z
# identities:
# i^2 = j^2 = k^2 = -1
# ij = k jk = i
# ki = j kj = -i
# ji = -k ik = -j
[a1,b1,c1,d1] = quatern(a);
[a2,b2,c2,d2] = quatern(b);
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;
retval = quatern(ri,rj,rk,rr);
endfunction