functionmain()clc,clearall;single(0,0,0),holdonaxisoff;title('体心立方结构');view(55,20);%spread();%cube_4();functionballs(r,x,y,z)[X,Y,Z]=sphere();X=x+r*X;Y=y+r*Y;Z=z+r*Z;surf(X,Y,Z);colormap([001]);functionsingle(x0,y0,z0)globalxyz;x=[1-1-1111-1-1]+x0;y=[1111-1-1-1-1]+y0;z=[11-1-1-111-1]+z0;fori=1:8balls(.1,x(i),y(i),z(i)),holdon;endcolormap([111])balls(0.2,x0,y0,z0),holdonfori=1:7line(x(i:i+1),y(i:i+1),z(i:i+1),'LineWidth',2),holdonendline([-1,1]+x0,[-1,-1]+y0,[-1,-1]+z0,'LineWidth',2),holdonline([-1,-1]+x0,[1,-1]+y0,[-1,-1]+z0,'LineWidth',2),holdonline([-1,-1]+x0,[1,-1]+y0,[1,1]+z0,'LineWidth',2),holdonline([1,1]+x0,[1,-1]+y0,[1,1]+z0,'LineWidth',2),holdonline([1,1]+x0,[1,1]+y0,[-1,1]+z0,'LineWidth',2)functionspread()single(0,0,0),holdonF(1)=getFrame;i=-1;spread_x(-i);F(2)=getFrame;spread_y(-i);F(3)=getFrame;spread_z(-i);F(4)=getFrame;i=1;spread_x(-i);F(1)=getFrame;spread_y(-i);F(1)=getFrame;spread_z(-i);F(1)=getFrame;movie(F);functionspread_x(e)globalxyz;x_front=[11110]*sign(e)+2*e;y_front=[11-1-10];z_front=[1-1-110];forj=1:4balls(.1,x_front(j),y_front(j),z_front(j));endballs(.2,x_front(5),y_front(5),z_front(5));line(x_front(1:4),y_front(1:4),z_front(1:4),'LineWidth',2)line([x_front(1),x_front(4)],[y_front(1),y_front(4)],[z_front(1),z_front(4)],'LineWidth',2)line([1*sign(e)+2*e,1],[1,1],[1,1],'LineWidth',2)line([1*sign(e)+2*e,1],[1,1],[-1,-1],'LineWidth',2)line([1*sign(e)+2*e,1],[-1,-1],[1,1],'LineWidth',2)line([1*sign(e)+2*e,1],[-1,-1],[-1,-1],'LineWidth',2)functionspread_y(e)globalxyz;x_right=[x(1:4),0];y_right=[y(1:4),0]*sign(e)+2*e;z_right=[z(1:4),0];forj=1:4balls(.1,x_right(j),y_right(j),z_right(j));endballs(.2,x_right(5),y_right(5),z_right(5));line(x_right(1:4),y_right(1:4),z_right(1:4),'LineWidth',2);line([x_right(1),x_right(4)],[y_right(1),y_right(4)],[z_right(1),z_right(4)],'LineWidth',2)line([-1,-1],[1*sign(e)+2*e,1],[-1,-1],'LineWidth',2)line([1,1],[1*sign(e)+2*e,1],[-1,-1],'LineWidth',2)line([1,1],[1*sign(e)+2*e,1],[1,1],'LineWidth',2)line([-1,-1],[1*sign(e)+2*e,1],[1,1],'LineWidth',2);functionspread_z(e)globalxyz;x_up=[11-1-10];y_up=[1-1-110];z_up=[11110]*sign(e)+2*e;forj=1:4balls(.1,x_up(j),y_up(j),z_up(j));endballs(.2,x_up(5),y_up(5),z_up(5));line(x_up(1:4),y_up(1:4),z_up(1:4),'LineWidth',2);line([x_up(1),x_up(4)],[y_up(1),y_up(4)],[z_up(1),z_up(4)],'LineWidth',2);line([1,1],[1,1],[1*sign(e)+2*e,1],'LineWidth',2)line([-1,-1],[1,1],[1*sign(e)+2*e,1],'LineWidth',2)line([-1,-1],[-1,-1],[1*sign(e)+2*e,1],'LineWidth',2)line([1,1],[-1,-1],[1*sign(e)+2*e,1],'LineWidth',2)functioncube_4()single(0,0,0),holdonF(1)=getFrame;i=1;single(2*i,0,0);F(2)=getFrame;single(0,2*i,0);F(3)=getFrame;single(2*i,2*i,0);F(4)=getFrame;single(0,0,2*i);F(5)=getFrame;single(2*i,0,2*i);F(6)=getFrame;single(0,2*i,2*i);F(7)=getFrame;single(2*i,2*i,2*i);F(8)=getFrame;movie(F);