Zbiór Mandelbrota w C (linux)

0

Witam,
mam do narysowania fraktal mandelbrota za pomocą tego algorytmu: http://en.wikipedia.org/wiki/Mandelbrot_set#Escape_time_algorithm.
Mój kod wygląda tak:

#include <stdio.h>
int main() {

const int dimx = 3500; 
const int dimy = 2000;
int i, j;
FILE * fp = fopen("first1.ppm", "wb"); /* b - tryb binarny */
fprintf(fp, "P6\n%d %d\n255\n", dimx, dimy);

for(j=0; j<dimy; ++j){
for(i=0; i<dimx; ++i){ 
static unsigned char color[3];
double x0=(double)i/1000.0;
double y0=(double)j/1000.0;
double x=0.0;
double y=0.0;
int iteration=0;
int max_iteration=1000;
int xtemp=0;


while ( (x*x + y*y < 2*2 ) && ( iteration < max_iteration ))
{
xtemp = x*x - y*y + x0;
y = 2*x*y + y0;
x = xtemp;
iteration = iteration + 1;
}
color[0]=iteration/4;
color[1]=iteration/4;
color[2]=iteration/4; 
fwrite(color,1,3,fp);
}
}
fclose(fp);
return 0;
} 

Jedyne co ten kod potrafi wypluć to kształt elipsy (może nie w tej obecnej formie, bo kombinowałem).

2
błąd jest w tej linijce napisał(a)
int xtemp=0;
0

Ahhh tyle nerwów przez niezgodne typy.. Dzięki przenajserdeczniejsze.

1 użytkowników online, w tym zalogowanych: 0, gości: 1