-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractols.c
116 lines (103 loc) · 2.7 KB
/
fractols.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractols.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asepulve <asepulve@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/19 14:47:52 by asepulve #+# #+# */
/* Updated: 2024/07/07 00:07:43 by asepulve ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
/*
* The only reason all of these function has the t_cx j param is the julia set.
*/
int burning_ship(t_cx z, t_cx j, int it)
{
int i;
t_cx c;
if ((pow(z.imag, 2) + pow(z.real, 2) >= 4))
return (0);
i = 0;
(void)j;
c = z;
while ((i < MAX_IT + it) && (pow(z.imag, 2) + pow(z.real, 2) < 4))
{
z = (t_cx){(z.real * z.real) - (z.imag *z.imag) + c.real,
fabs(z.real * z.imag) * -2 + c.imag};
i++;
}
return (i);
}
int alien(t_cx z, t_cx j, int it)
{
int i;
t_cx c;
(void)j;
c = z;
if ((pow(z.imag, 2) + pow(z.real, 2) >= 4))
return (0);
i = 0;
while ((i < MAX_IT + it) && (pow(z.imag, 2) + pow(z.real, 2) < 4))
{
z = (t_cx){(-1 * fabs(z.real) * z.real)
- fabs(z.imag * z.imag) + c.real, (z.real * z.imag * 2) + c.imag};
i++;
}
return (i);
}
int celtic(t_cx z, t_cx j, int it)
{
int i;
t_cx c;
(void)j;
c = z;
if ((pow(z.imag, 2) + pow(z.real, 2) >= 4))
return (0);
i = 0;
while ((i < MAX_IT + it) && (pow(z.imag, 2) + pow(z.real, 2) < 4))
{
z = (t_cx){fabs((z.real * fabs(z.real)) + (z.imag * z.imag)) + c.real,
(z.real * z.imag * 2) + c.imag};
i++;
}
return (i);
}
/*
* Julia needs the other imaginary point for it to render;
*/
int julia(t_cx z, t_cx j, int it)
{
int i;
if ((pow(z.imag, 2) + pow(z.real, 2) >= 4))
return (0);
i = 0;
while ((i < MAX_IT + it) && (pow(z.imag, 2) + pow(z.real, 2) < 4))
{
z = (t_cx){pow(z.real, 2) - pow(z.imag, 2) + j.real,
2 * z.real * z.imag + j.imag};
i++;
}
return (i);
}
/*
* If the coordenate converge we return the iterarion iterator value;
*/
int mandelbrot(t_cx z, t_cx j, int it)
{
int i;
t_cx c;
(void)j;
i = 0;
c = z;
while ((i < MAX_IT + it) && (pow(z.imag, 2) + pow(z.real, 2) < 4))
{
z = (t_cx){
pow(z.real, 2) - pow(z.imag, 2) + c.real,
2 * z.real * z.imag + c.imag
};
i++;
}
return (i);
}