资源描述:
《笛卡尔心形线代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、[X,Y,Z]=meshgrid(linspace(-3,3,101));%3D心型图方程如下;F=-X.^2.*Z.^3-(9/80).*Y.^2.*Z.^3+(X.^2+(9/4).*Y.^2+Z.^2-1).^3;hFigure=figure;sz=get(hFigure,'Position');set(hFigure,'Position',[sz(1)-0.15*sz(3)sz(2)1.3*sz(3)sz(4)]);set(hFigure,'color','w','menu','none')hAxes=axes('Parent',hFigur
2、e,'NextPlot','add',... 'DataAspectRatio',[111],... 'XLim',[30120],'YLim',[3565],'ZLim',[3075]);view([-3930]);axisoff%制作出动态的隐形效果;hiddenon%画出网格,制作网格动态效果;%快渲染心得背面:p=patch(isosurface(F,-0.001));set(p,'FaceColor','w','EdgeColor','w');%构造Y-Z平面,,描完函数在该平面的点:foriX=[35384145485154576
3、16467] plane=reshape(F(:,iX,:),101,101); cData=contourc(plane,[00]); xData=iX.*ones(1,cData(2,1)); plot3(hAxes,xData,cData(2,2:end),cData(1,2:end),'k'); pause(.1),drawnowend%构造X-Z平面,描完函数在该平面的点:foriY=[41444751555861] plane=reshape(F(iY,:,:),101,101); cData=contourc
4、(plane,[00]); yData=iY.*ones(1,cData(2,1)); plot3(hAxes,cData(2,2:end),yData,cData(1,2:end),'k'); pause(.1),drawnowend%构造X-Y平面,描完函数在该平面的点:foriZ=[363840424446485052545658606264666971] plane=F(:,:,iZ); cData=contourc(plane,[00]); startIndex=1; ifsize(cData,2)>(cData
5、(2,1)+1) startIndex=cData(2,1)+2; zData=iZ.*ones(1,cData(2,1)); plot3(hAxes,cData(1,2:(startIndex-1)),... cData(2,2:(startIndex-1)),zData,'k'); end zData=iZ.*ones(1,cData(2,startIndex)); plot3(hAxes,cData(1,(startIndex+1):end),... cDa
6、ta(2,(startIndex+1):end),zData,'k'); pause(.1),drawnowend%函数已经画完,接下来为文字部分;pause(.2)%设置字体大小,粗细,位置等,以下是打出I(心型图)Wendy;text(7,50,70,'I','fontWeight','bold','FontAngle','italic','fontsize',60)pause(.5)text(80,50,43,'Wendy','fontWeight','bold','FontAngle','italic','fontsize',60)pau
7、se(.2)line([2080],[5050],[52.552.5],'color','w')line([5050],[2080],[52.552.5],'color','w')line([5050],[5050],[3080],'color','w')%制作者签名;text(40,60,30,'roger2014.5.4','fontsize',8)text(35,45,30,'','fontsize',8)