-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_complex.c
58 lines (47 loc) · 1.65 KB
/
t_complex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* t_complex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dmoureu- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/16 16:55:41 by dmoureu- #+# #+# */
/* Updated: 2016/01/16 17:11:05 by dmoureu- ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
t_complex initcomplex(void)
{
t_complex nb;
nb.r = 0;
nb.i = 0;
return (nb);
}
t_complex addcomplex(t_complex d1, t_complex d2)
{
t_complex result;
result.r = d1.r + d2.r;
result.i = d1.i + d2.i;
return (result);
}
t_complex souscomplex(t_complex d1, t_complex d2)
{
t_complex result;
result.r = d1.r - d2.r;
result.i = d1.i - d2.i;
return (result);
}
t_complex multcomplex(t_complex d1, t_complex d2)
{
t_complex result;
result.r = d1.r * d2.r + ((-1) * d1.i * d2.i);
result.i = (d1.r * d2.i) + (d1.i * d2.r);
return (result);
}
t_complex offsetcomplex(t_env *e, int x, int y)
{
t_complex p;
p.r = 1.5 * (x - WIDTH / 2) / (0.5 * e->cam->z * WIDTH) + e->cam->movex;
p.i = (y - HEIGHT / 2) / (0.5 * e->cam->z * HEIGHT) + e->cam->movey;
return (p);
}