-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjung.c
99 lines (70 loc) · 2.74 KB
/
jung.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
code from qmnplane.cpp by Wolf Jung (C) 2007-2017
http://www.mndynamics.com/indexp.html
part of Mandel 5.15, which is free software; you can
redistribute and / or modify them under the terms of the GNU General
Public License as published by the Free Software Foundation; either
version 3, or (at your option) any later version. In short: there is
no warranty of any kind; you must redistribute the source code as well.
https://en.wikibooks.org/wiki/Fractals/mandel
*/
/*
Hit the key g to draw the equipotential line through the current point z (outside of Kc) or c (outside of M), or to specify the potential level.
the following code will be rewritten completely!!!
void QmnPlane::green
recursive function
*/
void green( mndynamics *f,
int st,
mdouble g,
int quality,
QColor color) //5, white
{ //trace the boundary ...
if (g <= 0 || type) return;
uint m = 1;
f->prepare(st, nmax, m, &g); //just to set nmax
int i, k, i0, k0, i1, k1, i2, k2, j, vert, side, sg, start, T;
//stop();
// set color
QPainter *p = new QPainter(buffer);
p->setPen(color);
for (T = 20 - kmax; T < kmax - 20; T += imax*2/quality)
{ for (vert = 0; vert <= 1; vert++)
{ for (side = -1; side <= 1; side += 2)
{
start = 10000; //no startpoint
if (vert) //vertical lines from above and below
{ if (f->green(st, hmid - ph*side*kmax + pw*T, vmid - pw*side*kmax + ph*T) <= g)
continue;
for (j = kmax-1; j >= -kmax/2; j--)
{ if (f->green(st, hmid + ph*side*j + pw*T, vmid - pw*side*j + ph*T) <= g)
{start = side*j; break;}
}
}
else//vert: horizontal lines from left and right
{ if (f->green(st, hmid + pw*side*imax - ph*T, vmid + ph*side*imax - pw*T) <= g)
continue;
for (j = imax-1; j >= -imax/2; j--)
{ if (f->green(st, hmid + pw*side*j - ph*T, vmid + ph*side*j - pw*T) <= g)
{start = side*j; break;} }
}// else vert
if (start == 10000) continue; //no startpoint
for (sg = -1; sg <= 1; sg += 2) //go in both directions
{ if (vert)
{ k0 = start; k1 = k0 + side; k2 = k1; i0 = T; i1 = T; i2 = i1 + sg;}
else
{ i0 = start; i1 = i0 + side; i2 = i1; k0 = T; k1 = T; k2 = k1 + sg;}
for (j = 1; j < 8*imax; j++)
{ if (i0 < -imax || i0 >= imax || k0 < -kmax || k0 >= kmax) break;
else p->drawLine(imax + i0, kmax + k0, imax + i0, kmax + k0);
if (f->green(st, hmid + pw*i2 + ph*k2, vmid + ph*i2 - pw*k2) <= g)
{i = i0; k = k0; i0 = i2; k0 = k2; i2 += (i1 - i); k2 += (k1 - k);}
else
{i = i1; k = k1; i1 = i2; k1 = k2; i2 += (i0 - i); k2 += (k0 - k);}
}//for j
}//for sg
}//for side
}//for vert
}//for T
delete p; update();
} //green