-
Notifications
You must be signed in to change notification settings - Fork 0
/
complex_math.c
47 lines (40 loc) · 1.49 KB
/
complex_math.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* complex_math.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fvieira <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/02 13:53:17 by fvieira #+# #+# */
/* Updated: 2022/12/02 13:53:19 by fvieira ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
t_complex add(t_complex a, t_complex b)
{
t_complex c;
c.x = a.x + b.x;
c.y = a.y + b.y;
return (c);
}
t_complex sqr(t_complex a)
{
t_complex c;
c.x = a.x * a.x - a.y * a.y;
c.y = 2 * a.x * a.y;
return (c);
}
t_complex mappoint(t_fractal *fractal, double x, double y)
{
t_complex c;
double l;
if (fractal->width < fractal->height)
l = fractal->height * fractal->zoom;
else
l = fractal->width * fractal->zoom;
x += fractal->xarrow ;
y += fractal->yarrow ;
c.x = 2 * fractal->radius * (x - fractal->width / 2) / l;
c.y = 2 * fractal->radius * (y - fractal->height / 2) / l;
return (c);
}