How to rotate axis by 180 degree?

9 次查看(过去 30 天)
CL
CL 2022-9-21
评论: CL 2022-9-21
By default, Matlab plots the my three unit vectors (x,y,z) in a way that the z-axis points up. How can I "roll" the orientation around the x-axis by 180 degrees so I can have the z-axis unit vector points down positively?
The right-hand rule has to be preserved - I'm not flipping any of the axis.
x=[1;0;0];
y=[0;1;0];
z=[0;0;1];
quiver3(0,0,0,x(1),x(2),x(3),'Color','green','LineWidth',2,'MaxHeadSize',0.5);
hold on;
quiver3(0,0,0,y(1),y(2),y(3),'Color','blue','LineWidth',2,'MaxHeadSize',0.5);
hold on;
quiver3(0,0,0,z(1),z(2),z(3),'Color','red','LineWidth',2,'MaxHeadSize',0.5);
axlims = norm(x)*1.2;
set(gca,'xlim',[-1,1]*axlims,'ylim',[-1,1]*axlims,'zlim',[-1,1]*axlims);
grid on;
axis square;

回答(1 个)

Chunru
Chunru 2022-9-21
x=[1;0;0];
y=[0;1;0];
z=[0;0;1];
quiver3(0,0,0,x(1),x(2),x(3),'Color','green','LineWidth',2,'MaxHeadSize',0.5);
hold on;
quiver3(0,0,0,y(1),y(2),y(3),'Color','blue','LineWidth',2,'MaxHeadSize',0.5);
hold on;
quiver3(0,0,0,z(1),z(2),z(3),'Color','red','LineWidth',2,'MaxHeadSize',0.5);
axlims = norm(x)*1.2;
set(gca,'xlim',[-1,1]*axlims,'ylim',[-1,1]*axlims,'zlim',[-1,1]*axlims);
grid on;
axis square;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set(gca, 'ZDir', 'reverse')
  2 个评论
CL
CL 2022-9-21
Ah no - as shown in both images in the question, both orientations has to obey the right-hand-rule. Reversing the orientation would break the the right-hand orientation and direction of rotation. I should have specified it better.
CL
CL 2022-9-21
ok ... I guess I'll just reverse the Y axis as well then to return to the right-hand orientation. thanks

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by