#include #include #include #include #define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825 #define PI2 (PI*2) #define SQ2 1.414213562373095048801688724209698078569671875376948073176679737990732478462 #define FI 1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204 #define SX 666 #define SY 666 #define NPT 100 #define RSD 666 #define V3D 0 /* #define SX 666 #define SY 666 #define NPT 1000 #define RSD 1923879 #define V3D 1 */ #define BPL ((SX*3+3)&~3) void seedr(unsigned int); unsigned int rnd(); unsigned int rndm(unsigned int); unsigned char bhdr[54]={ 0x42, 0x4D, 0x36, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char po[BPL]; double gr[SY][SX][3]; void drawit(); int main(int a, char **b) { FILE *o; int x, y, c; double t; unsigned char *p; srand(time(0)); drawit(); p=bhdr+2; *p++=x=54+BPL*SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8; p=bhdr+18; *p++=x=SX; *p++=x>>=8; *p++=x>>=8; *p++=x>>=8; *p++=x=SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8; if(!(o=fopen("voronoi.bmp", "wb"))) { fclose(o); printf("Couldn't open output file.\n"); return(0); } fwrite(bhdr, 54, 1, o); for(x=SX*3;x=1?255:t*255); fwrite(po, BPL, 1, o); } fclose(o); return(0); } int ptx[NPT], pty[NPT], ptz[NPT]; double ptc[NPT][3]; void drawit() { int x, y, c, n, bn, dx, dy, dz; unsigned int m, p; seedr(RSD); for(n=0;n>1)^(0x9908b0df&(0-(v&1)));} void gennewr() { int n; unsigned int v; for(n=0;n<227;++n) TEMPBLAH(n, n+1, n+397); for(;n<623;++n) TEMPBLAH(n, n+1, n-227); TEMPBLAH(623, 0, 396); rseedu=0; } #undef TEMPBLAH unsigned int rnd() { if(rseedu>=624) gennewr(); unsigned int v=rseeda[rseedu++]; v^=v>>11; v^=(v<<7)&0x9d2c5680; v^=(v<<15)&0xefc60000; v^=v>>18; return(v); } unsigned int rndm(unsigned int m) { unsigned int v, c=(0u-m)/m; while((v=rnd())/m>c); return(v%m); } //