Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"math.h" // sqrt
- #include"stdio.h" // fopen
- float a,b,c,x,y,z,u,v,w,i,j,d,s,t,R,G,B,X,Y,Z,A[600000]={0};unsigned l,N=0,r=9,
- p;void I(){t=99,d=a+5;for(j=0;j<3;j++,d-=5){s=d*x+b*y+c*z;u=s*x-d,v=s*y-b,w=s*z
- -c;w=u*u+v*v+w*w;if(w<4){w=-s-sqrt(4-w);if(w<t&w>0)t=w,i=j;}}w=(b-2)/y;if(w>0&w
- <t)t=w,i=3;}float U(){r+=r*r|5;return r*4.6566e-10f-1;}void D(){do x=U(),y=U(),
- z=U();while((s=x*x+y*y+z*z)>1);s=sqrt(s);if(x*u+y*v+z*w<0)s=-s;x/=s,y/=s,z/=s;}
- void S(){a+=t*x,b+=t*y,c+=t*z,u=w=0,v=2;if(i<3)u=a+(1-i)*5,v=b,w=c;if(i==1){s=(
- u*x+v*y+w*z)/2,x-=s*u,y-=s*v,z-=s*w,Z/=3;}else{D();if(!i)Y*=0.2,Z*=0.2;if(i>2)s
- =((int)a+(int)c)&1,X*=s,Y*=s;}}void W(){X=Y=Z=1;R=G=B=l=0;for(;I(),l<9;l++)if(t
- ==99)R+=X,G+=Y,B+=Z,l=9;else{S();if(i!=1)s=(u*x+v*y+w*z)*0.79,X*=s,Y*=s,Z*=s;}}
- void P(){N++;for(p=0;p<600000;){a=-9.5,b=0,c=-11,x=(p/3)%500*0.035-9,z=9-x;a+=U
- ()/40,y=9-p/1500*0.051,b+=U()/40;x-=a,y-=b,z-=c;a=-6;c=-10;j=sqrt(x*x+y*y+z*z);
- x/=j,y/=j,z/=j,W();A[p++]+=R,A[p++]+=G,A[p++]+=B;}}int main(){int i=0,q=6e5,p=q
- ,h[]={2<<16,2<<28,0,26214900,24};FILE*g=fopen("o.tga","wb");fwrite(h,2,9,g);for
- (;i<64;i++)P();for(l=0;v<q;v++){i=A[--p]/N*255;i=i>255?-1:i;fwrite(&i,1,1,g);}}
Advertisement
Add Comment
Please, Sign In to add comment