필터 지우기
필터 지우기

Quaternions, Transformation Matrix

조회 수: 5 (최근 30일)
hknatas
hknatas 2018년 11월 11일
편집: James Tursa 2020년 5월 8일
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.

채택된 답변

Bruno Luong
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
hknatas
hknatas 2018년 11월 11일
Thanks for your effort, I guess I understood what we did finally.
James Tursa
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개)

카테고리

Help CenterFile Exchange에서 Quaternion Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by