问题描述
我已经成功实现了维基百科文章中描述的 mandelbrot 集,但我不知道如何放大特定部分.这是我正在使用的代码:
I have successfully implemented the mandelbrot set as described in the wikipedia article, but I do not know how to zoom into a specific section. This is the code I am using:
+(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 范围内,减少这个数字会放大,但这根本不起作用.如何缩放?
It was my understanding that x0 should be in the range -2.5 - 1 and y0 should be in the range -1 - 1, and that reducing that number would zoom, but that didnt really work at all. How can I zoom?
推荐答案
首先,如果 max_iteration 为 15,您将看不到太多细节.我的每个点有 1000 次迭代作为基线,并且可以进行大约 8000 次迭代,直到它真的变得太慢而无法等待.
first off, with a max_iteration of 15, you're not going to see much detail. mine has 1000 iterations per point as a baseline, and can go to about 8000 iterations before it really gets too slow to wait for.
这可能有帮助:http://jc.unternet.net/src/java/com/jcomeau/Mandelbrot.java
这也是:http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand
这篇关于如何缩放 mandelbrot 集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!