|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
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)
|
|