In need of a quaternion example



reyssat said:     (by the date of Tue, 26 Oct 2010 23:26:01 +0200)

> Janek Kozicki a ?crit :
> > Hi,
> >
> > I don't know how to multiply two quaternions. Let's say that I want
> > to multiply two quaternions:
> >
> > (1,2,3,4)*(5,6,7,8)
> >
> > How do I do that?
> >   
> The quaternions i,j,k are v[1],v[2] and v[1] . v[2] (note the blank 
> around the dot, important when using subst).
> So you may try this :
> (%i2) load(atensor)$
> (%i3) init_atensor(quaternion)$
> (%i4) q(a,b,c,d):=a+b.v[1]+c.v[2]+d.v[1].v[2]$
> p:expand(atensimp(q(1,2,3,4).q(5,6,7,8)));
> (%o5) (%i5) 24*v[1] . v[2]+30*v[2]+12*v[1]-60
> (%i6) conj(x):=subst([v[1]=-v[1],v[2]=-v[2],v[1] . v[2]=-v[1] . v[2]] , x)$
> (%i7) conj(p);
> (%o7) -24*v[1] . v[2]-30*v[2]-12*v[1]-60
> 
> Note that if you try
> (%i8) p:expand(atensimp(q(a,b,c,d).q(e,f,g,h)));
> you get an awful answer. Remember first to
> (%i9) declare([a,b,c,d,e,f,g,h],scalar);
> then the answer is better (but the terms in v[1], v[2] and v[1] . v[2] 
> are not yet collected).

thanks a lot, this is something that I can start with!


-- 
Janek Kozicki                               http://janek.kozicki.pl/  |