-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.c
89 lines (82 loc) · 1.9 KB
/
checker.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* checker.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhenin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/27 16:29:48 by mhenin #+# #+# */
/* Updated: 2024/11/29 15:44:34 by mhenin ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int in_mandelbrot(double x, double y)
{
double t_x;
double t_y;
double temp_x;
int i;
t_x = 0;
t_y = 0;
i = 0;
while (MAX_ITERATION > i)
{
temp_x = (t_x * t_x) - (t_y * t_y);
t_y = 2 * t_x * t_y;
t_x = temp_x;
t_x += x;
t_y += y;
i++;
if ((t_x * t_x + t_y * t_y) > 4)
return (i);
}
return (0);
}
int in_julia(double x, double y, double c_x, double c_y)
{
double t_x;
double t_y;
double temp_x;
int i;
t_x = 0;
t_y = 0;
i = 0;
while (MAX_ITERATION > i)
{
temp_x = (x * x) - (y * y);
y = 2 * x * y;
x = temp_x;
x += c_x;
y += c_y;
i++;
if ((x * x + y * y) > 4)
return (i);
}
return (0);
}
int in_burningship(double x, double y)
{
double t_x;
double t_y;
double temp_x;
int i;
t_x = 0;
t_y = 0;
i = 0;
while (MAX_ITERATION > i)
{
if (t_x < 0)
t_x *= -1;
if (t_y < 0)
t_y *= -1;
temp_x = (t_x * t_x) - (t_y * t_y);
t_y = 2 * t_x * t_y;
t_x = temp_x;
t_x += x;
t_y += y;
i++;
if ((t_x * t_x + t_y * t_y) > 4)
return (i);
}
return (0);
}