-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathburning_ship.c
56 lines (50 loc) · 1.61 KB
/
burning_ship.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* burning_ship.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cquillet <cquillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/27 01:04:43 by cquillet #+# #+# */
/* Updated: 2017/10/29 16:42:09 by cquillet ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
#include "libft.h"
void burning_init(t_fractal *f)
{
f->plane = create_boxf(-2., 2., -2., 2.);
f->nb_iter_max = 35;
f->z0 = create_complex(0., 0.);
f->pause = 1;
f->power = 2;
clear_img(&(f->mlx.win.img));
}
static int burning_exit(t_cplx zn)
{
return (cplx_mod2(zn) > 4.);
}
/*
** z -> (|Re(z)| + i|Im(z)|)2 + c , pixel = c
*/
unsigned int burning_calc(t_fractal f, t_cplx z)
{
t_cplx zn;
t_cplx next;
t_cplx abs;
unsigned int n;
zn = f.z0;
n = 0;
while (n < f.nb_iter_max)
{
if (burning_exit(zn))
return (n);
abs = create_complex(ft_absf(zn.re), ft_absf(zn.im));
next = cplx_add(cplx_pow(abs, 2), z);
if (!cplx_cmp(next, zn))
return (f.nb_iter_max);
zn = next;
n++;
}
return (n);
}