Is quaternion multiplication associative?

4 ビュー (過去 30 日間)
Chamira Wickramasinghe
Chamira Wickramasinghe 2017 年 8 月 11 日
回答済み: James Tursa 2020 年 5 月 8 日
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.

回答 (1 件)

James Tursa
James Tursa 2020 年 5 月 8 日
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]

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by