-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
55 lines (47 loc) · 1.76 KB
/
utils.c
File metadata and controls
55 lines (47 loc) · 1.76 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abita <abita@student.42vienna.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/07 20:57:48 by abita #+# #+# */
/* Updated: 2025/08/07 20:57:52 by abita ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
double magnitude(t_complex z)
{
return (sqrt(z.real * z.real + z.imag * z.imag));
}
t_complex complex_square(t_complex z)
{
t_complex result;
result.real = (z.real * z.real) - (z.imag * z.imag);
result.imag = 2 * z.real * z.imag;
return (result);
}
t_complex complex_square_m(t_complex z)
{
t_complex result;
result.real = (z.real * z.real * z.real * z.real) - \
6 * ((z.real * z.real) * (z.imag * z.imag)) + \
(z.imag * z.imag * z.imag * z.imag);
result.imag = (4 * ((z.real * z.real * z.real) * (z.imag))) - \
(4 * ((z.real) * (z.imag * z.imag * z.imag)));
return (result);
}
void ft_color_fract(t_fractal *fract, int i)
{
if (i == fract->max_iter)
fract->color = BLACK;
else
fract->color = ((i + 1) * 255 / fract->max_iter) * BLUE;
}
void var_init(t_fractal *fract)
{
fract->max_iter = 80;
fract->zoom = 1.0;
fract->move_x = 0.0;
fract->move_y = 0.0;
}