From 1a444f533b3e92ae3ae181d238c80141e7335f01 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Tue, 5 Dec 2023 20:20:21 +0100 Subject: [PATCH] Add general function for constructing Julia sets This function has different prototype that mandelbrot function so some work should be done about unifying it for easier swapping of the two. This function may be used to construct specialized functions. --- julia.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 julia.c diff --git a/julia.c b/julia.c new file mode 100644 index 0000000..aa63a9a --- /dev/null +++ b/julia.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* julia.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/05 19:57:50 by ljiriste #+# #+# */ +/* Updated: 2023/12/05 20:16:54 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "vect2.h" +#include "complex.h" + +double general_julia(void *zeroth, double resolution, + void (*tested_f)(void *), int (*is_over_thresh)(void *)) +{ + int count; + + count = 0; + while (!is_over_thresh(zeroth) && count < 100 * resolution) + { + tested_f(zeroth); + ++count; + } + if (count == 100 * resolution) + return (-1); + return (fmod(count / 100., 1.)); +} -- 2.30.2