Quaternions, Transformation Matrix
2 ビュー (過去 30 日間)
古いコメントを表示
Hello.
As you see in the figure, my C matrix depends on q1, q2, q3 and q4 quaternions. I caculated all the q1(i),q2(i),q3(i),q4(i) values when i = 0:1:54000. Namely for 54000 iteration, I have 54000 different q1, q2, q3, q4 values. Right now, I want to calculate C matrix for i = 0:1:54000. As a result, I need 54000 different C matrices. For i = 1, q1(1), q2(1), q3(1) and q4(1) should be used and so on i need to reach i = 54000. As i say above, i have the code to calculate all q1,q2,q3 and q4. Just i need to insert these values to matrix respectively. I guess for matrices, i can't use the same plan as I calculated quternions.
Thanks for the help already.

0 件のコメント
採用された回答
Bruno Luong
2018 年 11 月 11 日
編集済み: Bruno Luong
2018 年 11 月 11 日
Such thing is straight forward in MATLAB
q1 = reshape(q1,1,1,[]);
q2 = reshape(q2,1,1,[]);
q3 = reshape(q3,1,1,[]);
q4 = reshape(q4,1,1,[]);
% The matrix is i C(:,:,i) for i=1,..., 54000
C = [q1.^2-q2.^2-q3.^2+q4.^2, 2*(q1.*q2+q3.*q4), 2*(q1.*q3-q2.*q4);
2*(q1.*q2-q3.*q4), -q1.^2+q2.^2-q3.^2+q4.^2, 2*(q2.*q3-q1.*q4);
2*(q1.*q3+q2.*q4), 2*(q2.*q3-q1.*q4), -q1.^2-q2.^2+q3.^2+q4.^2]
6 件のコメント
James Tursa
2020 年 5 月 8 日
編集済み: James Tursa
2020 年 5 月 8 日
@Bruno: Correct on that error catch. The C(2,3) term should have a + instead of a -.
Also, for the benefit of other readers, note that the quaternion to direction cosine matrix formula above (with the correction) assumes the following:
Quaternion is vector-scalar order. I.e., the vector is [q1;q2;q3] and the scalar is q4. Note that this does not match either the Aerospace Toolbox or the Robotics Toolbox, which have the scalar first and vector last.
Quaternion is either Right Chain right-handed Hamilton convention or Left Chain left-handed JPL convention. I.e., it must be one of the following:
v_body = q^-1 * v_ref * q with right-handed Hamilton convention (ij=k, jk=i, ki=j)
or
v_body = q * v_ref * q^-1 with left-handed JPL convention (ij=-k, jk=-i, ki=-j)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!