aboutsummaryrefslogtreecommitdiff
path: root/src/fractals/burningship.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-27 14:47:23 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-27 14:47:23 +0100
commitdab9efb7b745fe884fb72017591dce95978c19c4 (patch)
tree67de56f79c67a29f3b916593c8f2ee4ebd5df45d /src/fractals/burningship.c
parent7a5632ab67f95c561ce22a19352e963af3077a5b (diff)
downloadfractol-master.tar.gz
fractol-master.tar.bz2
fractol-master.zip
Optimization and norming a bitHEADmaster
Diffstat (limited to 'src/fractals/burningship.c')
-rw-r--r--src/fractals/burningship.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/fractals/burningship.c b/src/fractals/burningship.c
index fb950ed..07baf38 100644
--- a/src/fractals/burningship.c
+++ b/src/fractals/burningship.c
@@ -6,37 +6,33 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 16:15:49 by cacharle #+# #+# */
-/* Updated: 2020/02/26 13:20:36 by cacharle ### ########.fr */
+/* Updated: 2020/02/27 12:25:24 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
-#define BURNING_SHIP_MAX_ITERATION 20
-#define BURNING_SHIP_ESCAPE_RADIUS_SQUARED 4
+#define BURNING_SHIP_ESCAPE_RADIUS_SQUARED 4.0
-int burningship(t_state *state, t_complex z)
+int burningship(t_state *state, t_complex c)
{
- int n;
- double zr;
- double zi;
- double zr_square;
- double zi_square;
- double tmp;
+ int n;
+ t_complex z;
+ t_complex z_square;
+ double tmp;
(void)state;
- zr = z.r;
- zi = z.i;
+ z = c;
n = -1;
while (++n < state->iterations)
{
- zi_square = zi * zi;
- zr_square = zr * zr;
- if (zr_square + zi_square > BURNING_SHIP_ESCAPE_RADIUS_SQUARED)
+ z_square.i = z.i * z.i;
+ z_square.r = z.r * z.r;
+ if (z_square.r + z_square.i > BURNING_SHIP_ESCAPE_RADIUS_SQUARED)
break;
- tmp = zr_square - zi_square + z.r;
- zi = fabs(2.0 * zr * zi + z.i);
- zr = fabs(tmp);
+ tmp = z_square.r - z_square.i + z.r;
+ z.i = fabs(2.0 * z.r * z.i + c.i);
+ z.r = fabs(tmp);
}
return (n);
}