-2

I have calculated that the current Mandelbrot iterates 208,200 times. But if I use a break to control the iterations it outputs kinda like a printer that has ran out of ink half way through, so I am obviously not doing it correctly, does anyone know how iteration controls should be implemented?

 int iterations = 0;

 for (x = 0; x < x1; x ++)
    {
        for (y = 0; y < y1; y++)
        {

            // PAINT CONTROLS HERE

            if (iterations > 200000)
            {
                break;
            }
            iterations++;

        }
}
Stacker-flow
  • 1,251
  • 3
  • 19
  • 39
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Nov 07 '14 at 19:22

2 Answers2

1

You need to change the values of y1 and x1 to control the "depth" of your Mandelbrot set.

By breaking at a certain number of iterations, you've gone "deep" for a while (because x1 and y1 are large) and then just stop part way through.

MikeH
  • 4,242
  • 1
  • 17
  • 32
0

It's not clear what you're asking. But taking the two most obvious interpretations of "iterations":

1) You mean to reduce the maximum iterations per-pixel. I wouldn't say this affects the "smoothness" of the resulting image, but "smooth" is not a well-defined technical term in the first place, so maybe this is what you mean. It's certainly more consistent with how the Mandelbrot set is visualized.

If this is the meaning you intend, then in your per-pixel loop (which you did not include in your code example), you need to reset the iteration count to 0 for each pixel, and then stop iterating if and when you hit the maximum you've chosen. Pixels where you hit the maximum before the iterated value for the pixel are in the set.

Typically this maximum would be at least 100 or so, which is enough to give you the basic shape of the set. For fine detail at high zoom factors, this can be in the 10's or 100's of thousands of iterations.

2) You mean to reduce the number of pixels you've actually computed. To me, this affects the "smoothness" of the image, because the resulting image is essentially lower-resolution.

If this is what you mean, then you need to either change the pixel width and height of the computed image (i.e. make x1 and y1 smaller), or change the X and Y step sizes in your loop and then fill in the image with larger rectangles of the correct color.

Without a better code example, it's impossible to offer more specific advice.

Peter Duniho
  • 68,759
  • 7
  • 102
  • 136