-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmandelbrot2.cpp
More file actions
74 lines (59 loc) · 1.31 KB
/
mandelbrot2.cpp
File metadata and controls
74 lines (59 loc) · 1.31 KB
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
/*
* Program: Mandelbrot halmaz
* Dátum: 2014. február. 26.
* Tutor: Szabó Attila
* Tutoriált: Tuza József
*/
#include <png++/png.hpp>
#define N 500
#define M 500
#define MAXX 0.7
#define MINX -2.0
#define MAXY 1.35
#define MINY -1.35
void GeneratePNG( int tomb[N][M])
{
png::image< png::rgb_pixel > image(N, M);
for (int x = 0; x < N; x++)
{
for (int y = 0; y < M; y++)
{
image[x][y] = png::rgb_pixel(tomb[x][y], tomb[x][y], tomb[x][y]);
}
}
image.write("kimenet.png");
}
struct Komplex
{
double re, im;
};
int main()
{
int tomb[N][M];
int i, j, k;
double dx = (MAXX - MINX) / N;
double dy = (MAXY - MINY) / M;
struct Komplex C, Z, Zuj;
int iteracio;
for (i = 0; i < M; i++)
{
for (j = 0; j < N; j++)
{
C.re = MINX + j * dx;
C.im = MAXY - i * dy;
Z.re = 0;
Z.im = 0;
iteracio = 0;
while(Z.re * Z.re + Z.im * Z.im < 4 && iteracio++ < 255)
{
Zuj.re = Z.re * Z.re - Z.im * Z.im + C.re;
Zuj.im = 2 * Z.re * Z.im + C.im;
Z.re = Zuj.re;
Z.im = Zuj.im;
}
tomb[i][j] = 256 - iteracio;
}
}
GeneratePNG(tomb);
return 0;
}