本文主要是介绍【matlab】 动态绘制三维心形图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
[转载]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 == 1imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'DelayTime',0.5);elseimwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.5);end
close(i)
end
end
这篇关于【matlab】 动态绘制三维心形图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!