diff options
Diffstat (limited to 'src/serial-fractals.c')
| -rw-r--r-- | src/serial-fractals.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/serial-fractals.c b/src/serial-fractals.c index 2647d11..4e081c3 100644 --- a/src/serial-fractals.c +++ b/src/serial-fractals.c @@ -1,4 +1,5 @@ #include "fractals.h" +#include <math.h> #include "precision.h" #include "grids.h" @@ -59,6 +60,35 @@ void tricorn_grid(grid_t* grid, const size_t max_iterations){ /* * Computes the number of iterations it takes for a point z0 to become unbounded + * if the return value is equal to max_iterations, the point lies within the burningship set (oh no! I hope they have fire safety gear) + */ +size_t burning_ship(const CBASE complex z0, const size_t max_iterations) { + CBASE complex z = z0; + CBASE complex z_mod; + size_t iteration = 0; + + while (CABS(z) <= 2 && iteration < max_iterations) { + z_mod = RABS(CREAL(z)) + RABS(CIMAG(z))*I; + z = z_mod * z_mod + z0; + iteration++; + } + return iteration; +} + +/* + * Fills a grid with burning_ship values + */ +void burning_ship_grid(grid_t* grid, const size_t max_iterations){ + const size_t size = grid->size; + size_t* data = grid->data; + + for(size_t i = 0; i < size; i++){ + data[i] = burning_ship(grid_to_complex(grid, i), max_iterations); + } +} + +/* + * Computes the number of iterations it takes for a point z0 to become unbounded * if the return value is equal to max_iterations, the point lies within the multibrot set * This is implementation closely matches mandelbrot, but uses cpow which might degrade performance. */ |
