From da9941939798abe41caa07830a5605f0d131a2f2 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 1 Jun 2016 13:45:28 +1200 Subject: Coords are now centre of image rather than top left --- algorithms/burning-ship.c | 12 ++++++++---- algorithms/mandelbrot.c | 11 +++++++---- extra/burning-ship-lattice-gen.sh | 2 +- fractal-gen.c | 12 ++++++------ fractal-gen.h | 4 ++-- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/algorithms/burning-ship.c b/algorithms/burning-ship.c index 7e27e4b..6f8c9d9 100644 --- a/algorithms/burning-ship.c +++ b/algorithms/burning-ship.c @@ -34,17 +34,21 @@ void struct frame *f = &(d->parent_frame); unsigned int x,y,i; double a,b; + double left,top; double complex z,c; defaultsd(&d->parent_frame.scale, 3.5f); - defaultsd(&d->parent_frame.top, -2.2f); - defaultsd(&d->parent_frame.left, -2.2f); + defaultsd(&d->parent_frame.x, -0.45f); + defaultsd(&d->parent_frame.y, -0.45f); + + left = d->parent_frame.x - (d->parent_frame.scale / 2); + top = d->parent_frame.y - (d->parent_frame.scale / 2); /* FIXME document this */ - b = clust_id*(f->scale/size)+f->top; /* FIXME document this */ + b = clust_id*(f->scale/size)+top; /* FIXME document this */ for (y = clust_id; y < size; y += clust_total) { - a = d->core*(f->scale/size)+f->left; + a = d->core*(f->scale/size)+left; for (x = d->core; x < size; x += cores) { z = 0; c = a+I*b; diff --git a/algorithms/mandelbrot.c b/algorithms/mandelbrot.c index 51d0c43..33d7cde 100644 --- a/algorithms/mandelbrot.c +++ b/algorithms/mandelbrot.c @@ -34,18 +34,21 @@ void struct frame *f = &(d->parent_frame); unsigned int x,y,i; double a,b; + double left, top; double complex z,c; - defaultsd(&d->parent_frame.top, -1.75f); - defaultsd(&d->parent_frame.left, -2.5f); defaultsd(&d->parent_frame.scale, 3.5f); + defaultsd(&d->parent_frame.x, -0.75f); + defaultsd(&d->parent_frame.y, 0); + left = d->parent_frame.x - (d->parent_frame.scale / 2); + top = d->parent_frame.y - (d->parent_frame.scale / 2); /* FIXME document this */ - b = clust_id*(f->scale/size)+f->top; /* FIXME document this */ + b = clust_id*(f->scale/size)+top; /* FIXME document this */ for (y = clust_id; y < size; y += clust_total) { - a = d->core*(f->scale/size)+f->left; + a = d->core*(f->scale/size)+left; for (x = d->core; x < size; x += cores) { z = 0; c = a + I*b; diff --git a/extra/burning-ship-lattice-gen.sh b/extra/burning-ship-lattice-gen.sh index 1a39c0d..68f483e 100755 --- a/extra/burning-ship-lattice-gen.sh +++ b/extra/burning-ship-lattice-gen.sh @@ -1,3 +1,3 @@ #!/bin/sh -exec ./burning-ship-gen -x -1.8 -y -0.082 -z 0.09 $@ +exec ../burning-ship-gen -x -1.755 -y -0.037 -z 0.09 $@ diff --git a/fractal-gen.c b/fractal-gen.c index e80c96a..73bd25f 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -140,8 +140,8 @@ main(int argc, char **argv) /* FIXME repetition */ sections[i].core = i; sections[i].width = width; - sections[i].parent_frame.top = f.top; - sections[i].parent_frame.left = f.left; + sections[i].parent_frame.y = f.y; + sections[i].parent_frame.x = f.x; sections[i].parent_frame.scale = f.scale; sections[i].datasize = toalloc; fprintf(stderr, " -> Thread %lu\r", i); @@ -207,8 +207,8 @@ parse_args(int argc, char **argv) clust_id = 0; clust_total = 1; - f.left = nan(""); - f.top = nan(""); + f.x = nan(""); + f.y = nan(""); f.scale = nan(""); /* bail out early if no arguments are supplied */ @@ -228,8 +228,8 @@ parse_args(int argc, char **argv) case 'N': clust_id = atoi(optarg); break; case 'T': clust_total = atoi(optarg); break; - case 'x': f.left = atof(optarg); break; - case 'y': f.top = atof(optarg); break; + case 'x': f.x = atof(optarg); break; + case 'y': f.y = atof(optarg); break; case 'z': f.scale = atof(optarg); break; /* redundant case for '?', but explicitness is best */ diff --git a/fractal-gen.h b/fractal-gen.h index a103d1f..210d50f 100644 --- a/fractal-gen.h +++ b/fractal-gen.h @@ -29,8 +29,8 @@ #include struct frame { - double top; - double left; + double x; + double y; double scale; }; -- cgit v1.1 From 57437e21d2695a2e5202d76080caad1b8c645af5 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 1 Jun 2016 13:45:51 +1200 Subject: Fix race condition in child thread --- fractal-gen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal-gen.c b/fractal-gen.c index 73bd25f..1cc1713 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -152,7 +152,7 @@ main(int argc, char **argv) switch (child = fork()) { case 0: - while((x = s->idx) < s->datasize) { + while(1) { fprintf(stderr, "Thread %d: %.4f%%\r", cores-1, 100.f*(double)x/s->datasize); -- cgit v1.1 From ff85aafda23509c74f0cdaa45bcaa4721b6df59b Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 1 Jun 2016 16:27:15 +1200 Subject: Fix bug introduced with previous commit --- fractal-gen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal-gen.c b/fractal-gen.c index 1cc1713..0a09c41 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -155,7 +155,7 @@ main(int argc, char **argv) while(1) { fprintf(stderr, "Thread %d: %.4f%%\r", cores-1, - 100.f*(double)x/s->datasize); + 100.f*(double)s->idx/s->datasize); sleep(1); } break; -- cgit v1.1 From 45765795c2c50f85d79b0cd492ede26af79b774d Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 2 Jun 2016 14:14:14 +1200 Subject: Update README to reflect top,left -> centre changes --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 905be3c..4c14922 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,12 @@ Also note that `-N` should always be used together with `-T`. -t thread_multiplier Float > 0 Coefficient to multiply cores by in order to achieve count of worker threads to use. (1) - -x left position of left of image on the real axis (x+iy) - -y top position of top of image on the imaginary axis (x+iy) - -z scale width and height of image in units on the cartesian - plane + -x xval Float + x value of centre of image on the real axis (x+iy) + -y yval Float + y value of centre of image on the imaginary axis (x+iy) + -z scale Float + width and height of image (units on cartesian plane) -N cluster_id 0 <= Integer < cluster_total A unique ID used to determine which sections of the image this instance should work on. -- cgit v1.1 From fcc7c9dce8410bb14d9fe546d66010a01eee365e Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 19 Sep 2016 11:14:37 +1200 Subject: Allow running of wrapper script from outside its direectory --- extra/burning-ship-lattice-gen.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/burning-ship-lattice-gen.sh b/extra/burning-ship-lattice-gen.sh index 68f483e..0cb66a1 100755 --- a/extra/burning-ship-lattice-gen.sh +++ b/extra/burning-ship-lattice-gen.sh @@ -1,3 +1,5 @@ #!/bin/sh -exec ../burning-ship-gen -x -1.755 -y -0.037 -z 0.09 $@ +ourdir="$(dirname $0)" + +exec "${ourdir}/../burning-ship-gen" -x -1.755 -y -0.037 -z 0.09 $@ -- cgit v1.1 From 5ed1f38b2f515c6cebd8386de44c13a2b120c878 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 19 Sep 2016 17:46:58 +1200 Subject: Add interesting place to readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 4c14922..4aa63d8 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,11 @@ Check out [pgm-interlace][pgm-interlace] for a tool to do this job. I'm working on an example tool to do this, but there are so many palettes you could use that you might as well write your own. +### Areas of interest + +Use the `-x`, `-y` and `-z` parameters to see them. +Have a play with the iteration count; as a general rule you will need more iterations when the scale is decreased + + * Tiny lone mandelbrot (0.001643721971153 + 0.822467633298876i), scale = 0.00000000005 + [pgm-interlace]: https://github.com/phillid/pgm-interlace/ -- cgit v1.1