声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1154|回复: 0

[绘图技巧] 生成旋转面的matlab程序

[复制链接]
发表于 2016-7-25 11:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
今天做课件,需要一个生成旋转面的动画,就编了一个曲线 z=3*(y-2)^2 绕Z 轴旋转生成旋转面的程序,生成的动画见附件,希望对大家有点用。

clear
clc
mov=avifile('xuanzhuanmian4.avi');
y=1:0.01:2;
z=3*(y-2).^2;
x=zeros(size(y));
r=y;
theta=[pi/2,pi/2:pi/10:2.5*pi];
n=length(theta);
plot3(x,y,z,'k','LineWidth',2);
hold on
quiver3(0,0,0,-1,0,0,3,'k','filled','LineWidth',2);
quiver3(0,0,0,0,-1,0,3,'k','filled','LineWidth',2);
quiver3(0,0,0,0,0,1,4,'k','filled','LineWidth',2);
text(0,-0.5,4.2,'Z')
text(0,-3.5,0.3,'Y')
text(-3.5,0,0.3,'X')
axis equal
axis([-2,2,-2,2,0,4])
axis off
for i=1:n-1
    [rr,alpha1]=meshgrid(r,linspace(theta(i),theta(i+1),10));
    zz=repmat(z,10,1);
    xx=rr.*cos(alpha1);
    yy=rr.*sin(alpha1);
    surf(xx,yy,zz);   
    shading interp
    alpha(1)
    drawnow;
    pause(0.8)
    f=getframe(gcf);
    mov=addframe(mov,f);
end
hold off
mov=close(mov);


xuanzhuanmian.rar (45.65 KB, 下载次数: 1)
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-23 19:07 , Processed in 0.085960 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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