/*********************************************** * Julia3DfireGen.c * * Generates a RAW format file of a 3D image * of a Julia set (grayscale) * * C source file by Alberto Strumia * ************************************************/ #include /* definition of constants */ #define Radius 10 #define Cx 0.745429 #define Cy 0.11308 #define Side 0.6 #define M 700 #define Num 100 #define scale 1 #define co 1.41 #define si 1.41 #define x0 -1.9*Side #define y0 1.2*Side /* main program */ main() { int p, q, n, w, r[M]; double x, y, xx, yy, Incx, Incy; FILE *fp; fp = fopen("Julia.raw","w"); for (p = 1; p <= M; p++) { printf("%i %%\n", p*100/M); for (q = 1; q <= M; q++) { Incx = x0 - Side + 2*Side*(p*co+q*si)/M; Incy = y0 - Side + 2*Side*(-p*si+q*co)/M; x = Incx; y = Incy; w = 0; for ( n = 1; n <= Num; ++n) { xx = (x*x - y*y)*(x*x - y*y) - 4*x*x*y*y - Cx; yy = 4*x*y*(x*x - y*y) - Cy; x = xx; y = yy; if ( x*x + y*y > Radius ) { w = n; n = Num; } } if ( q >= w ) { r[q - w/scale] = w; } } for ( q = 1; q <= M; q++) { fprintf(fp, "%c", r[q] ); r[q] = 10; } } fclose(fp); } /* end of main program */