I am learning about quaternions right now, and I wanted to play around with some concepts I am learning.
e.g. take rotation of a point about an axis with specified angle.
th = 3.4;
v = Sqrt[1/3.0]*(i + j + k)
q = Cos[th] + Sin[th]*v;
qinv = Cos[th] - Sin[th]*v;
p = 2*i + 3*j + 4*k;
r = q * p *qinv // Expand
r = r//.{ i*i->-1, j*j->-1,k*k->-1,
i*j->k , j*i->-k,
j*k->i, k*j->-i,
k*i->j, i*k->-j}
Here I want to rotate the point p in three dimensions by the angle th with the axis given by the unit vector v.
So for that I basically just need to use replacement rules like did above.
The result I get is
0.391808 + 2.26121 i - 0.0435342 i^3 + 3.1959 j - 0.0653013 j^3 +
4.1306 k - 0.0870683 k^3
How do I tell Mathematica to replace 'i^3' etc. by '-i'? I would have thought Mathematica would be smart enough to use my 'i^2=-1' rule to figure this out.
Generalizing this question, if I am manipulating symbols (not just quaternions) how do I specify replacements so that the final answer is as 'simple' as possible?
FullForm[i*j]
andFullForm[j*i]
, they are the same. But fori^3
to-i
part, try this rule:p1 = Power[m_, n_] :> If[n > 2, -m^(n - 2), -m];
then doi^3//.p1
$\endgroup$