MATLAB Answers

Is quaternion multiplication associative?

5 views (last 30 days)
Chamira Wickramasinghe
Chamira Wickramasinghe on 11 Aug 2017
Answered: James Tursa on 8 May 2020
Hi,
I know that quaternions hold associative property,
which is A.(B.C) = (A.B).C
But, have a look at the code below
%%
t1 = sym('t1/2','real');
t2 = sym('t2/2','real');
t3 = sym('t3/2','real');
Q01 = [cos(t1) 0 0 sin(t1)];
Q12 = quatmultiply([cosd(45) sind(45) 0 0],[cos(t2) 0 0 sin(t2)]);
Q23 = quatmultiply([cosd(-45) sind(-45) 0 0],[cos(t3) 0 0 sin(t3)]);
X = quatmultiply(Q01,quatmultiply(Q12,Q23));
Y = quatmultiply(quatmultiply(Q01,Q12),Q23);
X-Y
%%
but there's a difference between 'X-Y'. How come?
can someone help me with this.
Thanks.

  0 Comments

Sign in to comment.

Answers (1)

James Tursa
James Tursa on 8 May 2020
You just need to simplify it to see that the result is in fact 0's. E.g., running your code gives this for X-Y:
ans =
[ cos(t1/2)*cos(t2/2)*cos(t3/2) - cos(t2/2)*sin(t1/2)*sin(t3/2) - (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 - (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 - (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 + (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 - (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 - (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 + (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 + (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2, cos(t3/2)*sin(t1/2)*sin(t2/2) - cos(t1/2)*sin(t2/2)*sin(t3/2) + (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 - (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 - (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 + (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 + (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 - (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 + (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 + (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2, (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 - (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 - sin(t1/2)*sin(t2/2)*sin(t3/2) - cos(t1/2)*cos(t3/2)*sin(t2/2) + (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 + (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 - (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 - (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 + (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 + (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2, cos(t1/2)*cos(t2/2)*sin(t3/2) + cos(t2/2)*cos(t3/2)*sin(t1/2) + (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 - (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 - (2^(1/2)*cos(t3/2)*((2^(1/2)*cos(t1/2)*sin(t2/2))/2 + (2^(1/2)*cos(t2/2)*sin(t1/2))/2))/2 - (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 - (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2 - (2^(1/2)*sin(t3/2)*((2^(1/2)*cos(t1/2)*cos(t2/2))/2 + (2^(1/2)*sin(t1/2)*sin(t2/2))/2))/2]
>> simplify(ans)
ans =
[ 0, 0, 0, 0]

  0 Comments

Sign in to comment.


Translated by