Skip to content

Instantly share code, notes, and snippets.

View camel-cdr's full-sized avatar

Camel Coder camel-cdr

  • 17:00 (UTC +02:00)
View GitHub Profile
@camel-cdr
camel-cdr / torus.c
Last active December 19, 2022 15:30
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;
@camel-cdr
camel-cdr / list.c
Created March 5, 2021 21:51
Remember kids, C's got namespaces.
struct list { struct list *list; };
struct list *
list(struct list *list)
{
list:
if (list->list && (list = list->list))
goto list;
return list;
}
@camel-cdr
camel-cdr / random.h
Last active March 5, 2021 21:48
How to generate unbiased uniform random floating-point numbers including all representable values. An excerpt from the random number library I'm currently developing.
/*
* 5.2 Uniform real distribution -----------------------------------------------
*
* Generating uniform random floating-point numbers might seem easy at first
* glance, just cast the output of a PRNG to the desired float type and divide
* by the biggest possible output of the PRNG to obtain a random float between
* 0 and 1 that can now be scaled up.
* Though as before this straightforward approach is biased.
*
* For the next part, I assume you are already acquainted with the IEEE 754