我已經成功實現了mandelbrot集,如維基百科文章中所述,但我不知道如何放大特定部分。這是我使用的代碼:如何縮放mandelbrot集
+(void)createSetWithWidth:(int)width Height:(int)height Thing:(void(^)(int, int, int, int))thing
{
for (int i = 0; i < height; ++i)
for (int j = 0; j < width; ++j)
{
double x0 = ((4.0f * (i - (height/2)))/(height)) - 0.0f;
double y0 = ((4.0f * (j - (width/2)))/(width)) + 0.0f;
double x = 0.0f;
double y = 0.0f;
int iteration = 0;
int max_iteration = 15;
while ((((x * x) + (y * y)) <= 4.0f) && (iteration < max_iteration))
{
double xtemp = ((x * x) - (y * y)) + x0;
y = ((2.0f * x) * y) + y0;
x = xtemp;
iteration += 1;
}
thing(j, i, iteration, max_iteration);
}
}
這是我的理解是X0應該在-2.5範圍 - 1,Y0應在-1範圍 - 1,和減少數量將會放大,但那根本沒有用。我如何縮放?
此外,整個集合包含在-2
2010-12-10 04:06:39
對於「永無止境的縮放」,我相信分形算法本身的一些特性被使用。 – 2010-12-10 04:21:02