Why the coordinate doesn't make sense after rotation matrix (rotx)?

18 ビュー (過去 30 日間)
Jiali
Jiali 2020 年 6 月 17 日
編集済み: hknatas 2023 年 11 月 10 日
Hello,
I got confused about the rotation matrix results. I want to rotate the structure around the z-axis with theta first, and then rotate around x-axis for phi.
theta=60;
phi=30;
R=rotx(phi)*rotz(theta);
R*[1; 0; 0];
% use rotation matrix to transform coordinate
% [X,Y,Z] is original coordinate
[X,Y,Z]=ndgrid(xa,ya,za);
[ie,je,ke]=size(X);
a=[X(:),Y(:),Z(:)];
% new coordinate
anew=R*(a.');
The result is [0.5; 0.75;0.433] for the vector of x-axis. But in my opinion, the new x-axis should be [0.5;-0.866;0]. I am not sure whether my understanding is wrong. Whether I can use rotation matrix to get the correct coordinate?
  1 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 6 月 17 日
Which rotx() function are you using? One from MATLAB's phsased Phased Array System Toolbox or some other source?

サインインしてコメントする。

採用された回答

David Goodmanson
David Goodmanson 2020 年 6 月 18 日
Hi Jiali,
from your results it looks like you are using the usual form of the rotation matrices,
function M = Rx(theta)
% angle is in DEGREES
c = cosd(theta); s = sind(theta);
M = [1 0 0
0 c -s
0 s c]
end
function M = Ry(theta)
% angle is in DEGREES
c = cosd(theta); s = sind(theta);
M = [ c 0 s
0 1 0
-s 0 c]
end
function M = Rz(theta)
% angle is in DEGREES
c = cosd(theta); s = sind(theta);
M = [c -s 0
s c 0
0 0 1]
end
which produce counterclockwise rotation of an object when looking down at the appropriate rotation axis coming up out of the page.
By 'rotating the structure' it sounds like you meant rotating the object, leaving the axes in place. In that case
Rx(30)*Rz(60)*[1;0 0]
ans =
0.5000
0.7500
0.4330
is correct. On the other hand, if you wish to rotate the coordinate axes and leave the object in place, then for the same physical rotation you change the signs of rotation and reverse the order of matrix mutiplication:
Rz(-60)*Rx(-30)*[1;0 0]
ans =
0.5000
-0.8660
0
  1 件のコメント
hknatas
hknatas 2023 年 11 月 10 日
編集済み: hknatas 2023 年 11 月 10 日
Can you provide me some references about this topic? I have a similar problem and with your solution I obtained the correct results. However, I couldn't find any references explaining what you've written. All references I followed so far just gives the conventional DCM explanation.
Let's assume that I have two different reference frames and a point. The point is represented with respect to the first frame with a vector. I would like to express the exact same point with respect to the second frame. I know the direction cosine matrix (DCM) between these two reference frames. As far as I understood from your answer, it is not enough to multiply this DCM with the vector that is representing the point with respect to the first frame. However, all references I examined so far claim that this is the way. I am really confused and would like further explanation if you can provide some references.
Edit: Let me clarify my confusion with an example. I have two reference frames. Let's name them as the first and second frames. I can obtain my second frame by rotating my first frame -30 degree around the positive x-axis and then rotate 180 degrees around the newly formed z-axis. So according to the math I know, I calculate the complete rotation as:
However, when I use "Rotation Angle to DCM" block in MATLAB/Simulink, I obtain:
which is different.
Now, let's assume that I have a point represented as [0,0,1] in the first frame. I would like to obtain that point's vector representation in the second frame so I make the calculation:
However, the correct answer [0, 0.5, 0.8660]. If I used the DCM that obtained from the MATLAB/Simulink, then I conclude the correct answer.
Thanks in advance,
Kind regards.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxes Transformations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by