jbikker

tinypt_v3

Jan 3rd, 2022
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include"math.h" // sqrt
  2. #include"stdio.h" // fopen
  3. float a,b,c,e,x,y,z,u,v,w,i,j,k,d,s,t,R,G,B,X,Y,Z,A[15<<17]={0};unsigned l,N=0,r=
  4. 9,p,q=15<<17;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*
  5. y-b,w=s*z-c;w=u*u+v*v+w*w;if(w<4){w=-s-k*sqrt(4-w);if(w<t&w>0)t=w,i=j;}}w=(b-2)/y
  6. ;if(w>0&w<t)t=w,i=3;}float U(){r+=r*r|5;return r*4.6566e-10f-1;}void W(){X=Y=Z=1;
  7. R=G=B=l=0,e=0.8;for(;k=e>1?-1:1,I(),l<9;l++)if(t==99)j=pow(1-y,5)/2,s=1-y/2,s*=s/
  8. 2,R+=s*X+j,G+=s*Y+j*j,B+=Z/2,l=9;else{a+=t*x,b+=t*y,c+=t*z;u=w=0,v=2;if(i<3)u=a+(
  9. 1-i)*5,v=b,w=c;if(i>1){do x=U(),y=U(),z=U();while((s=x*x+y*y+z*z)>1);s=sqrt(s);if
  10. (x*u+y*v+z*w<0)s=-s;x/=s,y/=s,z/=s;s=i<3?1:((int)a+(int)c)&1,X*=s,Y*=s;}else{s=(u
  11. *x+v*y+w*z)/-2;if(i==1&(U()+1)/2>pow(1-s*k,5)){s*=k;k*=(e*s-sqrt(fabs(1-e*e*(1-s*
  12. s))))/2;x=e*x+k*u;y=e*y+k*v;z=e*z+k*w;e=1/e;}else x+=s*u,y+=s*v,z+=s*w;}if(i>1)s=
  13. (u*x+v*y+w*z)*0.8,X*=s,Y*=s,Z*=s;}}void P(){N++;for(p=0;p<q;){x=p/3%1024/50.-9,a=
  14. U()/40-9.5,b=U()/40,c=-16,z=9-x,y=9-p/3072/31.,x-=a,y-=b,z-=c;a+=3;c+=6;j=sqrt(x*
  15. x+y*y+z*z);x/=j,y/=j,z/=j;W();A[p++]+=R,A[p++]+=G,A[p++]+=B;}}int main(){int h[]=
  16. {2<<16,2<<28,0,41944064,24},i=0,p=q;FILE*g=fopen("o","wb");fwrite(h,2,9,g);for(;i
  17. <64;i++)P();for(l=0;v<q;v++){i=A[--p]/N*255;i=i>255?-1:i;fwrite(&i,1,1,g);}}
  18.  
Advertisement
Add Comment
Please, Sign In to add comment