简体   繁体   中英

How to draw 3D Cartesian coordinate frame using Matlab?

如何在Matlab中绘制一个坐标系,它看起来像在不同轴具有不同颜色的链接3D坐标系中? 例如,红色线段表示x轴,绿色线段表示y轴,蓝色线段测量 z 轴。

One way to do it is to use the line command. You specify the XYZ coordinates of the origin and then some length as the delta from the origin.

% origin
origin = [1 2 3];
% length of frame vectors
delta = 10;
% x-axis
line('XData', [origin(1) origin(1) + delta], 'YData', [origin(2) origin(2)],...
    'ZData', [origin(3) origin(3)], 'Color','r');
% y-axis
line('XData', [origin(1) origin(1)], 'YData', [origin(2) origin(2) + delta],...
    'ZData', [origin(3) origin(3)], 'Color','g');
% z-axis
line('XData', [origin(1) origin(1)], 'YData', [origin(2) origin(2)],...
    'ZData', [origin(3) origin(3) + delta], 'Color','b');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM