% Code for generating blobs Mike Mangini % Aug 24th, 2006 clear colormap(gray(256)); phicor=[0,pi,pi,0]; thcor=[pi/2,8*pi/27,0,pi/6]; %load V n=[2,3,4];%only uses 2,3,&4th harmonic [x,y,z]=sphere(300); BB=size(z); %size of z BB=BB(1,1); [th,phi,r]=cart2sph(x,y,z); Tr=r*5; C=ones(BB)*120; C(1,1)=255; C(1,2)=0; axis equal HM=8; % how many different blobs do you want this prog makes 2D space of HWxHW blobs for rot2=1:HM for rot3=1:HM for i=1:3 if i==1 plusth=(rot2*pi/(HM-1)); elseif i==2 plusth=(rot3*2*pi/((HM-1)*3)); else plusth=2*pi/(HM-1); % only 2nd and 3rd harmonic change the shape 4th is static end [th,phi,r]=cart2sph(x,y,z); addR=exp(.8*(cos(n(i)*(-(th)+thcor(i)+plusth))+cos(n(i)*(phi)+phicor(i)))); Tr=Tr+addR; if i==2 phi=phi+pi/4; end [xn,yn,zn]=sph2cart(th,phi,Tr); end Tr=r*5; % Showing the blob just created surf(xn,yn,zn,C); shading interp; material dull; axis equal; axis off; light('Position',[0,-2,1]); light('color',[ .5 .5 .5 ]); light('Position',[0,2,1]); light('color',[ .5 .5 .5 ]); for cus_angle=0:15:90 % you can change this loop however you want to make diff views view(cus_angle,15) pause(.1) N1=int2str(rot2); N2=int2str(rot3); N3=int2str(cus_angle); FO=strcat('blob-',N1,'-',N2,'-',N3,'.tif') print(FO,'-dtiff'); % imwrite(outfile,map,FO,'tif'); end end end