【问题标题】:how to zoom mandelbrot set如何缩放曼德布罗集
【发布时间】:2010-12-10 12:14:55
【问题描述】:

我已经成功实现了维基百科文章中描述的 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
  • 对于“永无止境的缩放”,我相信使用了分形算法本身的某些属性。

标签: objective-c mandelbrot


【解决方案1】:

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

x0 = cx + (i/width - 0.5)*lx;

y0 = cy + (j/width - 0.5)*ly;

它的作用是首先将像素缩小到单位间隔(0

【讨论】:

  • 谢谢!发现您的回复很有用,因为我还遇到了扩展 Mandelbrot 集的需要。但是,我可以问一下在这种情况下 x0 和 y0 指的是什么。我对C语言不熟悉
【解决方案2】:

首先,max_iteration 为 15,您不会看到太多细节。我的每个点有 1000 次迭代作为基线,并且可以进行大约 8000 次迭代,然后才真正变得太慢而无法等待。

这可能会有所帮助:http://jc.unternet.net/src/java/com/jcomeau/Mandelbrot.java

这也是:http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand

【讨论】:

  • 我正在创建一个大系列,希望它运行得更快,所以把它降低到 15 ......以前是 1000。
  • 缩放越多,您需要越多的迭代才能看到点之间的差异。迭代太少,你只会看到一种颜色。在更高的缩放比例下,您将需要更多的迭代来显示细节。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-26
  • 2017-12-03
  • 1970-01-01
  • 2013-12-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多