MATLAB Answers

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

조회 수: 22(최근 30일)
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.
R*[1; 0; 0];
% use rotation matrix to transform coordinate
% [X,Y,Z] is original coordinate
% new coordinate
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 17 Jun 2020
Which rotx() function are you using? One from MATLAB's phsased Phased Array System Toolbox or some other source?

댓글을 달려면 로그인하십시오.

채택된 답변

David Goodmanson
David Goodmanson 18 Jun 2020
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]
function M = Ry(theta)
% angle is in DEGREES
c = cosd(theta); s = sind(theta);
M = [ c 0 s
0 1 0
-s 0 c]
function M = Rz(theta)
% angle is in DEGREES
c = cosd(theta); s = sind(theta);
M = [c -s 0
s c 0
0 0 1]
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 =
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by