I'm still relatively new to Java. I've been working on a program to display the mandelbrot set. My current code generates an image that is close, but not quite the mandelbrot set. This is my generation code:
private void generateMap () {
// scale, ITERATIONS, map, and SIZE are class variables
// cR and cI are the actual coordinates in the set being used
double cR = -2*scale;
double cI = -2*scale;
// a and b step through the array used to store the drawing
// and control when the loop exits
for (int a = 0; a < SIZE.width; a++)
{
for (int b = 0; b < SIZE.height; b++)
{
double xR = 0;
double xI = 0;
int iter = 0;
while (iter < ITERATIONS)
{
xR = (xR*xR-xI*xI) + cR;
xI = (2*xR*xI) + cI;
if (xR*xR+xI*xI > 4) {
map[a][b] = iter;
iter = ITERATIONS;
}
iter++;
}
cI += INCREMENT*scale;
}
cI = -2*scale;
cR += INCREMENT*scale;
}
}
My netbeans project is downloadable from here.
Here's a screenshot of the current output: