資源描述:
《笛卡爾心形線代碼.doc》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
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%制作出動態(tài)的隱形效果;hiddenon%畫出網(wǎng)格,制作網(wǎng)格動態(tài)效果;%快渲染心得背面:p=patch(isosurface(F,-0.001));set(p,'FaceColor','w','EdgeColor','w');%構(gòu)造Y-Z平面,,描完函數(shù)在該平面的點(diǎn):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%構(gòu)造X-Z平面,描完函數(shù)在該平面的點(diǎn):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%構(gòu)造X-Y平面,描完函數(shù)在該平面的點(diǎn):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%函數(shù)已經(jīng)畫完,接下來為文字部分;pause(.2)%設(shè)置字體大小,粗細(xì),位置等,以下是打出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)