Objective c 如何缩放mandelbrot集

Objective c 如何缩放mandelbrot集,objective-c,mandelbrot,Objective C,Mandelbrot,我已经成功地实现了wikipedia文章中描述的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) {

我已经成功地实现了wikipedia文章中描述的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);
    }
}
+(void)createSetWithWidth:(int)width Height:(int)Height Thing:(void(^)(int,int,int,int,int))Thing
{   
对于(int i=0;i虽然(((x*x)+(y*y))首先,max_迭代为15次,但您不会看到太多细节。我的每个点有1000次迭代作为基线,可以进行大约8000次迭代,直到它真正变得太慢而无法等待

这可能有助于:

这也是:

假设中心是(cx,cy),并且要显示的长度是(lx,ly),可以使用以下缩放公式:

x0=cx+(i/宽度-0.5)*lx

y0=cy+(j/宽度-0.5)*ly


它首先将像素缩小到单位间隔(0)我正在创建一个大集合,希望它运行得更快,所以将它降到15…以前是1000。缩放越多,需要看到点之间差异的迭代次数越多。迭代次数太少,只能看到所有一种颜色。缩放越大,需要更多迭代来显示细节。此外,整个集合包含有在-2