Skip to content

Instantly share code, notes, and snippets.

@camel-cdr
Last active December 19, 2022 15:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camel-cdr/d4770de29306a78c6418c3e8e953226e to your computer and use it in GitHub Desktop.
Save camel-cdr/d4770de29306a78c6418c3e8e953226e to your computer and use it in GitHub Desktop.
obfuscated raymarcher
i,j,k,L;
#include <time.h>
float X,Y,Z,l,t,x,y,z,
A,S,C;r(X,Y)float*X,*Y;{A
=*X,S=sin(l),C=cos(l);*X=A*C
-*Y*S,*Y=A*S+*Y *C;}main()
{char*p,s[L=( W+1)*H];
printf("\x1b" "[2J");r
:p=s;for(i=0; i<H;++i,
*p++=10)for(j =0;j<W;
++j,*p++="@$" "#=:,-"
". "[k=t])for (X=(2.*
j-W)/W,Y=(2.* i-H)/H
,Z=3,l=sqrt(X *X+Y*Y
+Z),X/=l,Y/=l ,Z/=l*l
,t=k=0;k<50&&~ (l<.05||
(t+=l)>8&&(t= 8));++k
)x=X*t,y=Y*t ,z=Z*t-
5,l=clock() *(l=1./
CLOCKS_PER_SEC ),r(&y,&z
),l/=2,r(&x,& y),x=sqrt
(x*x+z*z)-2.2,l =sqrt(x*x+
y*y)-.4;puts("\x1b[H"
);write(1,s,L);
goto r;}
/* by camel-cdr */
/* cc torus.c -DH=32 -DW=64 -lm */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment