/** Copyright: Peter Cappello Feel free to use this code as is, provided that you leave these comments in place. Feel free to modify this code, provided that you explicitly indicate that your code is based on Peter Cappello's code A Mandelbrot Complet */ public class MandelbrotComplet //implements Complet { double X, Y, // lower left corner of region edg; // edge length of region int res, // resolution: discretize region // into a grid of res X res squares lim, // iteration limit cnt[][];// iteration count for each square public MandelbrotComplet(double x, double y, double e, int r, int l, int c[][]) { X = x; Y = y; edg = e; res = r; lim = l; cnt = c; } public void compute() { double gap = edg/res, // edge length of square r, i, // the square's representative point zR, zI, t1, t2; int count, row, col; for (row = 0, i = Y; row < res; row++, i += gap) for (col = 0, r = X; col < res; col++, r += gap) { // compute count for this box for (count = 1, zR = r, zI = i; (t1 = zR*zR) + (t2 = zI*zI) < 4.0 && count < lim; count++) { zI = 2.0*zR*zI + i; zR = t1 - t2 + r; } cnt[row][col] = count; } } }