From c6f87a62b31325e91bc8c847de9b20647a9b1cd8 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 24 Feb 2020 15:39:22 +0100 Subject: Added julia fractal and mouse modify julia constant --- src/fractals/julia.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/fractals/julia.c') diff --git a/src/fractals/julia.c b/src/fractals/julia.c index e69de29..d1afb46 100644 --- a/src/fractals/julia.c +++ b/src/fractals/julia.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* julia.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 15:17:38 by cacharle #+# #+# */ +/* Updated: 2020/02/24 15:36:04 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->julia_const.i; + zr += state->julia_const.r; + } + return (n); +} -- cgit