blob: 136cf1317b304a9a63a733f14c6ca3d5a1884661 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 15:17:38 by cacharle #+# #+# */
/* Updated: 2020/02/24 16:06:57 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
#define JULIA_MAX_ITERATION 20
#define JULIA_ESCAPE_RADIUS_SQUARED 100
int julia(t_state *state, t_complex z)
{
int n;
double zr;
double zi;
double zr_square;
double zi_square;
zr = z.r;
zi = z.i;
n = -1;
while (++n < JULIA_MAX_ITERATION)
{
zi_square = zi * zi;
zr_square = zr * zr;
if (zr_square + zi_square > JULIA_ESCAPE_RADIUS_SQUARED)
break;
zi = 2.0 * zr * zi;
zr = zr_square - zi_square;
zi += state->c.i;
zr += state->c.r;
}
return (n);
}
|