tags:

views:

44

answers:

1

I'm trying to visualize Mandelbrot set with OpenGL and have found very strange behaviour when it comes to smooth coloring.

Let's assume, for the current complex valueC, algorithm have escaped after n iterations when Z had been proven to be more than 2.

I programmed coloring part like this:

if(n==maxIterations){
   color=0.0; //0.0 is black in OpenGL when put to each channel of RGB 
              //Points in M-brot set are colored black.
} else {
   color = (n + 1 - log(log(abs(Z)))/log(2.0) )/maxIterations; 
   //continuous coloring algorithm, color is between 0.0 and 1.0
   //Points outside M-brot set are colored depending of their absolute value,
   //from brightest near the edge of set to darkest far away from set.
}
glColor3f(color ,color ,color );
//OpenGL-command for making RGB-color from three channel values. 

The problem is, this just don't work well. Some smoothing is noticable, but it's not perfect.

But when I add two additional iterations (just found this somewhere without explanation)

Z=Z*Z+C; 
n++; 

in the "else"-branch before calculating a color, the picture comes out to be absolutely, gracefully smooth.

Can anybody please explain this behaviour? Why do we need to place additional iterations in coloring part after checking the point to be in set?

A: 

For now it seems that "additional iterations" idea has no convincing formulas for it, if not counting the fact it just works.

In one old version of Wikipedia's Mandelbrot article there are lines about Continuous Coloring:

Second, it is recommended that a few extra iterations are done so that z can grow. If you stop iterating as soon as z escapes, there is the possibility that the smoothing algorithm will not work.

Better than nothing.

furikuretsu