diff options
| -rw-r--r-- | src/fractals.c | 7 | ||||
| -rw-r--r-- | src/serial-fractals.c | 17 | ||||
| -rw-r--r-- | src/util.c | 22 | ||||
| -rw-r--r-- | src/util.h | 12 |
4 files changed, 4 insertions, 54 deletions
diff --git a/src/fractals.c b/src/fractals.c index 3c131f3..80ff32e 100644 --- a/src/fractals.c +++ b/src/fractals.c @@ -9,7 +9,6 @@ #include "fractals.h" - int main(const int argc, char *argv[]) { //default values size_t iterations = 1000; @@ -36,14 +35,16 @@ int main(const int argc, char *argv[]) { } - grid_t* grid = create_grid(x_res, y_res); + const double complex lower_left = -2 + -2*I; + const double complex upper_right = 2 + 2*I; + grid_t* grid = create_grid(x_res, y_res, lower_left, upper_right); if(!grid) return 1; const size_t size = grid->size; size_t* data = grid->data; for(size_t i = 0; i < size;i++){ - data[i] = multibrot(lattice_to_complex(i, x_res, y_res), iterations, 3); + data[i] = multibrot(grid_to_complex(grid, i), iterations, 3); } for(size_t i = 0; i < size; i++){ diff --git a/src/serial-fractals.c b/src/serial-fractals.c index 55cd431..a5f9841 100644 --- a/src/serial-fractals.c +++ b/src/serial-fractals.c @@ -1,6 +1,4 @@ #include "fractals.h" -#include "grids.h" -#include "util.h" /* * Computes the number of iterations it takes for a point z0 to diverge * if the return value is equal to max_iterations, the point lies within the mandelbrot set @@ -17,21 +15,6 @@ size_t mandelbrot(const double complex z0, const size_t max_iterations) { return iteration; } -/* - * Fills a grid with the a complex sit - */ -void mandelbrot_grid(grid_t* grid, vec2 resolution, const size_t iterations){ - if(!grid || !grid->data) return; - const size_t size = grid->size; - - set_grid(grid, 0); //unnecessary step - - - size_t* data = grid->data; - for(size_t i = 0; i < size; i++){ - data[i] = mandelbrot(lattice_to_complex(i, resolution), iterations); - } -} /* * Computes the number of iterations it takes for a point z0 to diverge diff --git a/src/util.c b/src/util.c deleted file mode 100644 index b76da0b..0000000 --- a/src/util.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "util.h" - -/* - * Converts a grid point into an complex number - */ -double complex lattice_to_complex(const size_t index, const vec2 resolution) { - const double x_min = -2.0; - const double x_max = 2.0; - const double y_min = -2.0; - const double y_max = 2.0; - - const double x_step = (x_max - x_min) / (double)resolution.x; - const double y_step = (y_max - y_min) / (double)resolution.y; - - const size_t x_index = index % resolution.x; - const size_t y_index = index / resolution.x; - - const double x = x_min + x_index * x_step; - const double y = y_min + y_index * y_step; - - return x + y * I; -} diff --git a/src/util.h b/src/util.h deleted file mode 100644 index 798b73b..0000000 --- a/src/util.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include <complex.h> -#include <stddef.h> - -typedef struct { - size_t x; - size_t y; -} vec2; - -double complex lattice_to_complex(const size_t index, const vec2 resolution); - |
