-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfractals.c
More file actions
69 lines (62 loc) · 1.79 KB
/
fractals.c
File metadata and controls
69 lines (62 loc) · 1.79 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rburgsta <rburgsta@student.42heilbronn. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/28 19:45:36 by rburgsta #+# #+# */
/* Updated: 2022/11/28 19:45:36 by rburgsta ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int julia(t_dta *dta)
{
int n;
double x_buf;
n = 0;
while (dta->x * dta->x + dta->y * dta->y <= 4 && n < dta->iter)
{
x_buf = dta->x * dta->x - dta->y * dta->y + dta->re;
dta->y = 2 * dta->x * dta->y + dta->im;
dta->x = x_buf;
n++;
}
return (n);
}
int mandelbrot(t_dta *dta)
{
int n;
double x_re;
double y_im;
double x_buf;
n = 0;
x_re = 0;
y_im = 0;
while (x_re * x_re + y_im * y_im <= 4 && n < dta->iter)
{
x_buf = x_re * x_re - y_im * y_im + dta->x;
y_im = 2 * x_re * y_im + dta->y;
x_re = x_buf;
n++;
}
return (n);
}
int tricorn(t_dta *dta)
{
int n;
double x_re;
double y_im;
double x_buf;
n = 0;
x_re = 0;
y_im = 0;
while (x_re * x_re + y_im * y_im <= 4 && n < dta->iter)
{
x_buf = x_re * x_re - y_im * y_im + dta->x;
y_im = -2 * x_re * y_im + dta->y;
x_re = x_buf;
n++;
}
return (n);
}