php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 282|回复: 0

MATLAB:三维空间图形旋转代码

[复制链接]

2627

主题

2634

帖子

9336

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
6587
贡献
0
注册时间
2021-4-14
最后登录
2024-4-26
在线时间
667 小时
QQ
发表于 2022-10-18 22:59:06 | 显示全部楼层 |阅读模式
[mw_shl_code=applescript,true]%生成三维空间的圆
t  = 0:0.01:2*pi;%圆滑性设置
x = 3*sin(t);
y = 3*cos(t);
z = 2+zeros(size(t));
% x = zeros(size(t));
% y = 3*sin(t);
% z = 3*cos(t);
l = plot3(x,y,z);
axis('equal','on',[-5,5,-5,5,-5,5]);

%绕轴旋转
l = plot3(x,y,z);
lineNum = 500;
axis('equal','on',[-5,5,-5,5,-5,5]);
theta = linspace(0,2*pi,lineNum);
c = colormap(jet(lineNum));%以一个三列数组的形式返回颜色图,包含行数与当前图窗的颜色图相同。
for ii = 1:lineNum
    hGroup1(ii) = hgtransform('Parent',gca);
    hGroup1(ii).Matrix = makehgtform('yrotate',theta(ii));   
    lGroup1(ii) = copyobj(l,gca);
    lGroup1(ii).Color = c(ii,;   
    lGroup1(ii).Parent = hGroup1(ii);
    drawnow %旋转动图,如果不需要可删。
    if ii ==1
        [A,map] = rgb2ind(frame2im(getframe(gcf)),256);
        imwrite(A,map,'1.gif','LoopCount',65535,'DelayTime',0);
    else if mod(ii,5) == 0
             [A,map] = rgb2ind(frame2im(getframe(gcf)),256);
             imwrite(A,map,'1.gif','WriteMode','append','DelayTime',0);
        end
    end
end[/mw_shl_code]





上一篇:MATLAB:16QAM调制与解调代码
下一篇:QPSK在AWGN信道下的仿真代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-26 19:07 , Processed in 0.298939 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表