From fe5637a5d6e2c2f0283ee3fb31a92a641386d1df Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Wed, 17 Jan 2024 10:34:55 +0100 Subject: [PATCH] Add check to mandelbrot to for visual correctness Coordinates too far from the fractal had incorrect color. --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 4de9972..f397d53 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/27 14:29:26 by ljiriste #+# #+# */ -/* Updated: 2024/01/16 14:31:25 by ljiriste ### ########.fr */ +/* Updated: 2024/01/17 10:29:34 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,6 +79,8 @@ double mandelbrot(double x, double y, double resolution) count = 0; z.r = 0; z.i = 0; + if (complex_norm(c) > 4) + return (0.01); while (complex_norm(z) < threshold && count < 100 * resolution) { z = complex_add(complex_mul(z, z), c); -- 2.30.2