Mandelbrot Set in Java

Screenshot of Mandelbrot program
Links: video, image 1, image 2
The Mandelbrot set is defined as the set of all complex numbers for which the sequence Z(n) as n nears infinity is unbounded, where Z(n+1) is defined as Z(n)^2 + c, Z(0) = c, and c is the number that is being checked. For example, using 1 + i as c will result in (1 + i), (1 + 3i), (-7 + 7i), (1 + 99i), ... You can see that this sequence is unbounded as the magnitude -- or absolute value -- of the number will forever increase. If, however, i is used as the number c, then the resulting sequence is i, -1 + i, -i, -1 + i, ... Since this sequence remains bounded, it is within the Mandelbrot set. The pictures of the Mandelbrot set that are generated are essentially complex numbers plotted on a Cartesian plane -- with the a (real) value on the y axis, and the b (imaginary) value on the x axis. For the calculations, the real and imaginary parts are represented as separate doubles, and are converted to screen coordinates when rendering.
The controls are arrow keys to move, '[' and ']' to increase/decrease number of max iterations (high number is better when zoomed in a lot, as precision is lost otherwise), minus to zoom out, click and drag to zoom in to a specific area on the screen.
I use two threads to render the fractal -- one for each half of the screen, as I wanted to make use of my dual-core to make rendering faster. The colours are based on the number of iterations it took to determine that the point is not within the set. If the iteration count reached the maximum iteration limit, then the number is in the set. Otherwise, the higher the iteration count, the brighter the colour. The more iterations, the more accurate the drawing (and obviously takes longer to draw), so as you increase max iterations you will see that there is less and less black (as some of the numbers on the outside edges of the black parts that were originally determined as being in the set turn out not to be in the set when going through more iterations).
If you want to try running it yourself, here's a JAR file: link
August 28th, 2009 - 16:01
That’s cool stuff. If you want to create more fractals, you should try a program called Apophysis.
August 28th, 2009 - 16:04
Oh, nevermind. I see that you have already tried the program.