Is quaternion multiplication associative?

조회 수: 5 (최근 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