0
我的輸出沒有顯示分形這個分形實現有什麼問題?
void mandelbrotFractal()
{
float MAX = 200;
float numIterations;
float ci;
float cr;
float zi;
float zr;
loadPixels();
for(int j = 0; j < height; j++)
{
for(int i = 0; i < width; i++)
{
//H[-2.0,2.0]
//V[-1.5,1.5]
cr = - 2.0 + ((i*(2.0+2.0))/width) ;
ci = - 1.5 + ((j*(1.5+1.5))/height);
numIterations = 0;
zi =0;
zr =0;
while(numIterations < MAX)
{
float zrSquared = (zr*zr);
float ziSquared = (zi*zi);
zr = zrSquared - ziSquared + cr;
zi = 2.0*(zr*zi) + ci;
numIterations = numIterations + 1;
if((zr*zr) + (zi*zi) > 4.0)
break;
}
color r = int((numIterations % 32) * 7);
color g = int((numIterations % 16) * 14);
color b = int((numIterations % 128) * 2);
if(numIterations == MAX)
pixels[j*width + i] = color(0);
else
pixels[j*width + i] = color((numIterations % 32) * 7,(numIterations % 16) * 14, (numIterations % 128) * 2);
}
}
updatePixels();
}
Bort! BORT! BORT! – Cheeso 2011-04-09 17:17:29
他被命名爲Mandelbrot,而不是Mandelbort。 – Phrogz 2011-04-09 17:19:03