blob: 3f2aaaac4742fcd0e2dd99f4a6e69bcdf2523ee3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package fractals;
/**
* An example of the use of our pixel drawing framework
* @author Sjaak Smetsers
* @version 1.0, 14-03-2013
*/
public class Mandelbrot {
public Mandelbrot() {
MainWindow fractal_win = new MainWindow ();
}
public static void main(String args[]) {
Mandelbrot mandelbrot = new Mandelbrot();
}
public static int mandelNumber(double x, double y, int repetitions) {
double x_n = x, y_n = y;
int n = 0;
while (x_n * x_n + y_n * y_n <= 4 && n <= repetitions) {
double new_x_n = x_n * x_n - y_n * y_n + x;
y_n = 2 * x_n * y_n + y;
x_n = new_x_n;
n++;
}
return n;
}
}
|