diff options
author | Leonard Kugis <leonardkugis@gmail.com> | 2018-01-16 01:21:27 +0100 |
---|---|---|
committer | Leonard Kugis <leonardkugis@gmail.com> | 2018-01-16 01:21:27 +0100 |
commit | c4b5e0a48835b6bdbf4d3d92fd42b29a22662ed4 (patch) | |
tree | 807f2c1ac0010ce91f5560d6bf852ecca45a221a /src/sets.c | |
parent | 9d46c7e44b0c8e0625894dbb688e9b2804d83c9d (diff) |
Mandelbrot drawing possible
Diffstat (limited to 'src/sets.c')
-rw-r--r-- | src/sets.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/sets.c b/src/sets.c new file mode 100644 index 0000000..6787a6e --- /dev/null +++ b/src/sets.c @@ -0,0 +1,46 @@ +/* + * sets.c + * + * Created on: 15.01.2018 + * Author: Superleo1810 + */ + +#include "sets.h" + +u32 mandelbrot_s(double x, double y, u32 iterations) +{ + double cx = x, cy = y, x2; + u32 m = 0; + while(m <= iterations && (x*x)+(y*y) <= 4) + { + x2 = x; + x = (x*x) - (y*y) + cx; + y = 2.0*x2*y + cy; + m++; + } + return m; +} + +u32 mandelbrot_r(double x, double y, u32 iterations) +{ + return _mandelbrot_r(x, y, 0.0, 0.0, 0, iterations, 4.0); +} + +u32 _mandelbrot_r(double x, double y, double zx, double zy, u32 n, u32 iterations, double threshold) +{ + if ((n <= iterations) && ((zx * zx + zy * zy) < threshold)) { + double zx_new = (zx * zx - zy * zy + x); + double zy_new = (2 * zx * zy + y); + if ((zx_new == zx) && (zy_new == zy)) { + return iterations; + } + n = _mandelbrot_r(x, y, zx_new, zy_new, n + 1, iterations, threshold); + } + return n; +} + +u32 julia(double x, double y, u32 iterations) +{ + // TODO: Julia-Menge + return 0; +} |