开发者

How do I zoom into the mandelbrot set?

I can generate a 400x400 image of the Mandelbrot set from minReal to maxReal and from minImaginary to maxImaginary. So,

makeMandel(minReal, maxReal, minImaginary, maxImaginary);

I need to modify it so that I can have,

makeMandel(centerX, centerY, Zoomlevel);
// generates a region of the mandelbrot set centered at centerX,centerY at a zoom level of Zoomlevel

(Considering zoom level represents the distance between the pixels and is given by the formula Zoom level n = 2 ^ (-n) so that zoom 开发者_如何学编程level 1 means pixels are 0.5 units apart, zoom level 2, 0.25 and so on...)

My question is how do I calculate the arguments of the first makeMandel function from the arguments of the second one? I know that the first function is capable of zooming and moving around but I don't know how to calculate the correct numbers for any given center and zoom level.

I've been trying to get this working for more than three days now and I'm really confused. I tried drawing tables, etc... on paper and working it out. I read most documents that you find on Google when searching for the mandelbrot set and a couple of past stackoverflow questions but I still don't understand. Please help me out.


You may solve it the following way. If you have the two definitions

centerX = (minReal + maxReal)/2
sizeX = maxReal - minReal

you can calculate extends on the axis via

minReal = centerX - sizeX/2
maxReal = centerX + sizeX/2

The size then is calculated using the zoomLevel:

sizeX = 2^(-zoomLevel) * baseSize

The same formulas hold for y and imaginary axis.

sizeY = 2^(-zoomLevel) * baseSize   
minImaginary = centerY - sizeY/2
maxImaginary = centerY + sizeY/2

The only thing to define as a constant is your baseSize, i.e. the extend in real and imaginary axis when zoomLevel is zero. You may consider different baseSize in real and imaginary direction to cover an non-square aspect ratio of your image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜