Hardcode threshold value for mandelbrot and tricorn
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 19 Jan 2024 12:45:58 +0000 (13:45 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 19 Jan 2024 12:45:58 +0000 (13:45 +0100)
fractals.c
fractol.h
main.c

index 790fa355fa484911aed0a16424f8d251bb08c1fc..3b04f849db7c2f28b341f71dbe9b419a7570d69d 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/12/05 19:57:50 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/01/19 11:30:08 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/01/19 13:43:01 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -39,12 +39,12 @@ double      mandelbrot(t_set_man *settings, double x, double y)
 
        c.r = x;
        c.i = y;
-       count = 0;
-       z.r = 0;
-       z.i = 0;
+       count = 1;
+       z.r = x;
+       z.i = y;
        if (complex_norm(c) > 4)
                return (0);
-       while (complex_norm(z) < settings->threshold && count < settings->detail)
+       while (complex_norm(z) < 256 && count < settings->detail)
        {
                z = complex_add(complex_mul(z, z), c);
                ++count;
@@ -67,7 +67,7 @@ double        tricorn(t_set_man *settings, double x, double y)
        z.i = 0;
        if (complex_norm(c) > 4)
                return (0);
-       while (complex_norm(z) < settings->threshold && count < settings->detail)
+       while (complex_norm(z) < 256 && count < settings->detail)
        {
                z = complex_add(complex_mul(complex_conj(z), complex_conj(z)), c);
                ++count;
index da1a0291b3a9a446a0f037879521ad51645ad573..1c8c7910f4de61110b686d087f51136480ba5b67 100644 (file)
--- a/fractol.h
+++ b/fractol.h
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/11/11 18:51:29 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/01/18 17:12:40 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/01/19 13:43:18 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -44,7 +44,6 @@ typedef struct s_view t_view;
 struct s_set_man
 {
        int     detail;
-       int     threshold;
        int     color_stability;
 };
 typedef struct s_set_man       t_set_man;
diff --git a/main.c b/main.c
index f66669cf69e80c3a89cda68331ad2d2aa4478633..aca56f01a71229f8593e0851a6720f7bfe387559 100644 (file)
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/10/27 14:29:26 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/01/19 11:21:04 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/01/19 13:44:02 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -276,8 +276,7 @@ void        parse_args(int argc, char **argv, t_session *s)
        if (argc == 0)
                free(argv);
        s->set.man.detail = 1000;
-       s->set.man.threshold = 1000;
-       s->set.man.color_stability = 100;
+       s->set.man.color_stability = 1000;
        s->img.width = 1000;
        s->img.height = 1000;
        s->img.undersample_max = 5;