-
Notifications
You must be signed in to change notification settings - Fork 0
/
julia_bonus.c
128 lines (116 loc) · 3.8 KB
/
julia_bonus.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cnascime <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/17 22:49:06 by cnascime #+# #+# */
/* Updated: 2023/03/20 13:22:22 by cnascime ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol_bonus.h"
/* The Julia set is named after the French mathematician Gaston Julia who
investigated their properties circa 1915 and culminated in his paper in 1918.
The Julia set consists of values such that an arbitrarily small perturbation can
cause drastic changes in the sequence of iterated function values, as opposed to
the Fatou set, which consists of values with the property that all nearby values
behave similarly under repeated iteration of the function. Thus the behaviour of
the function on the Julia set is "chaotic", while the Fatou set has a "regular"
behaviour (Julia "laces" and Fatou "dusts").
*/
// Sparkles
double julia1(t_setup *ol, double zreal, double zimag)
{
double tempimag;
ol->iteration = 0.0;
ol->creal = -0.63;
ol->cimag = 0.43;
while (ol->iteration < MAXITERATIONS
&& ((zreal * zreal) + (zimag * zimag)) < 4)
{
tempimag = 2.0 * zreal * zimag + ol->cimag;
zreal = (zreal * zreal) - (zimag * zimag) + ol->creal;
zimag = tempimag;
ol->iteration++;
}
if (ol->iteration == MAXITERATIONS)
return (MAXITERATIONS);
return (ol->iteration);
}
// Spirals
double julia2(t_setup *ol, double zreal, double zimag)
{
double tempimag;
ol->iteration = 0.0;
ol->creal = -0.76;
ol->cimag = 0.05;
while (ol->iteration < MAXITERATIONS
&& ((zreal * zreal) + (zimag * zimag)) < 4)
{
tempimag = 2.0 * zreal * zimag + ol->cimag;
zreal = (zreal * zreal) - (zimag * zimag) + ol->creal;
zimag = tempimag;
ol->iteration++;
}
if (ol->iteration == MAXITERATIONS)
return (MAXITERATIONS);
return (ol->iteration);
}
// Hamburger
double julia3(t_setup *ol, double zreal, double zimag)
{
double tempimag;
ol->iteration = 0.0;
ol->creal = -1.1;
ol->cimag = 0.0;
while (ol->iteration < MAXITERATIONS
&& ((zreal * zreal) + (zimag * zimag)) < 4)
{
tempimag = 2.0 * zreal * zimag + ol->cimag;
zreal = (zreal * zreal) - (zimag * zimag) + ol->creal;
zimag = tempimag;
ol->iteration++;
}
if (ol->iteration == MAXITERATIONS)
return (MAXITERATIONS);
return (ol->iteration * 42 * 83);
}
// Snowflakes
double julia4(t_setup *ol, double zreal, double zimag)
{
double tempimag;
ol->iteration = 0.0;
ol->creal = 0.29;
ol->cimag = 0.03;
while (ol->iteration < MAXITERATIONS
&& ((zreal * zreal) + (zimag * zimag)) < 4)
{
tempimag = 2.0 * zreal * zimag + ol->cimag;
zreal = (zreal * zreal) - (zimag * zimag) + ol->creal;
zimag = tempimag;
ol->iteration++;
}
if (ol->iteration == MAXITERATIONS)
return (MAXITERATIONS);
return (ol->iteration);
}
// Circle
double julia5(t_setup *ol, double zreal, double zimag)
{
double tempimag;
ol->iteration = 0.0;
ol->creal = -0.0;
ol->cimag = 0.0;
while (ol->iteration < MAXITERATIONS
&& ((zreal * zreal) + (zimag * zimag)) < 4)
{
tempimag = 2.0 * zreal * zimag + ol->cimag;
zreal = (zreal * zreal) - (zimag * zimag) + ol->creal;
zimag = tempimag;
ol->iteration++;
}
if (ol->iteration == MAXITERATIONS)
return (MAXITERATIONS);
return (ol->iteration);
}