威望0
积分7946
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-21
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7946
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-21
- 在线时间
- 763 小时
|
[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] |
|