-
Notifications
You must be signed in to change notification settings - Fork 1
/
mandelbrot.c
59 lines (51 loc) · 1.04 KB
/
mandelbrot.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "fractal.h"
int iterative_method (point *p, options *opt) {
point c, pp;
int k = 0;
double xx = p->x*p->x, yy = p->y*p->y;
c.x = p->x;
c.y = p->y;
while (xx + yy < 4) {
pp.x = xx - yy + c.x;
pp.y = 2*p->x*p->y + c.y;
p->x = pp.x;
p->y = pp.y;
xx = pp.x*pp.x;
yy = pp.y*pp.y;
k++;
if (k >= opt->kmax)
return 0;
}
return k;
}
int close_to_solution (point *p, options *opt) {
(void) p;
(void) opt;
return 0;
}
void method_print (FILE *f, int s, int k, int max, options *opt) {
double p = ((double)fabs(k))/max;
double C[3] = {0, 0, 0}, H[3] = {0, 0, 0};
(void) s;
(void) opt;
int r, g, b;
if (k > 0) {
H[0] = p*360;
H[1] = 1;
/* H[2] = 1-pow(2*(p-0.5),N);*/
if (p > 0.95)
H[2] = 1.0*(1 - (p - 0.95)/(1 - 0.95));
else if (p > 0.05)
H[2] = 1;
else
H[2] = 1.0*p/0.05;
hsv_to_rgb(H, C);
}
r = max*C[0];
g = max*C[1];
b = max*C[2];
/* if (k > 0)*/
fprintf(f, "%d %d %d\n", r, g, b);
/* else*/
/* fprintf(f, "0 0 0\n");*/
}