matlab动态绘制三维心形图

标签:
matlabisosurfacegif三维心 |
分类: matlab |
matlab动态绘制三维心形图程序如下,核心是isosurface函数,verts存储了心形曲面各点的坐标,而faces存储了各点的连接顺序。
clear
filename='heart';
[x,y,z]=meshgrid(linspace(-3,3));
p=(x.^2+(9/4)*y.^2+z.^2-1).^3-x.^2.*z.^3-(9/80)*y.^2.*z.^3;
[faces,verts,colors] = isosurface(x,y,z,p,0,x);
for i=1:9
figure(i)
pp=patch('Faces',faces(1:284+i*1000,:),'Vertices',verts);
set(pp,'FaceColor','red','EdgeColor','none');
view(-30,24)
axis off
axis equal
axis tight
camlight
lighting gouraud
pause(0.5)
f(i) = getframe(i);
imind = frame2im(f(i));
[imind,cm] = rgb2ind(imind,256);
if i == 1
else
end
close(i)
end
http://s16/mw690/003cvAxDzy6Xj2r1m7dbf&690