How to zoom in on a mandelbrot kit?

I can create a 400x400 Mandelbrot set image from minReal to maxReal and from minImaginary to maxImaginary. In this way,

makeMandel(minReal, maxReal, minImaginary, maxImaginary); 

I need to change it so that I can

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

(Given that the zoom level is the distance between the pixels and is given by the formula Zoom level n = 2 ^ (-n), so zoom level 1 means that the pixels are at a distance of 0.5 units, zoom level 2, 0.25 and so Further...)

My question is: how to calculate the arguments of the first makeMandel function from the arguments of the second? I know that the first function is able to scale and move, but I do not know how to calculate the correct numbers for any given center and zoom level.

I am trying to get this work to work for more than three days, and I'm really confused. I tried to draw tables, etc. On paper and work out. I read most of the documents you found on Google when looking for the mandelbrot suite and a couple of past stack questions, but I still don't get it. Please help me.

+4
source share
1 answer

You can solve it as follows. If you have two definitions

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

you can calculate the length along the axis through

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

Then the size is calculated using zoomLevel :

 sizeX = 2^(-zoomLevel) * baseSize 

The same formulas are valid for y and the imaginary axis.

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

The only thing that can be defined as a constant is your baseSize , i.e. expansion on the real and imaginary axis when zoomLevel is zero. You can consider different baseSize in real and imaginary directions to cover the non-square aspect ratio of your image.

+4
source

All Articles