-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex_op.c
More file actions
45 lines (40 loc) · 1.43 KB
/
Copy pathcomplex_op.c
File metadata and controls
45 lines (40 loc) · 1.43 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* complex_op.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hamalmar <hamalmar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/29 22:45:01 by h #+# #+# */
/* Updated: 2024/09/21 11:44:25 by hamalmar ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void init_complex(t_complex *p, double a, double bi)
{
p->a = a;
p->b = bi;
}
/*
@brief This function will compute (a + bi)^2
@param zn Complex number
*/
void square_complex(t_complex *zn)
{
double a;
double b;
a = zn->a;
b = zn->b;
zn->a = (a * a) - (b * b);
zn->b = 2 * a * b;
}
/*
@brief This function will add two complex numbers to each other.
@param zn Complex number
@param c The constant complex number added in the mandelbrot equation.
*/
void add_complex(t_complex *zn, t_complex *c)
{
zn->a += c->a;
zn->b += c->b;
}