From c1bbaf7edaebfabbfca80162b6944c17b00d3834 Mon Sep 17 00:00:00 2001 From: Nikola Date: Fri, 3 Jul 2026 21:10:42 +0200 Subject: [PATCH] Fixed tricorn_V3.c to adjust mathematical direction based on height sign --- Implementierung/main.c | 1 + Implementierung/tricorn_V3.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Implementierung/main.c b/Implementierung/main.c index 9abf40a..4df4c51 100644 --- a/Implementierung/main.c +++ b/Implementierung/main.c @@ -21,6 +21,7 @@ void benchmarking(void) { // do the benchmarking } // REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920,1080 -o image.bmp -C +// AND FOR NEGATIVE HEIGHT: ./tricorn -s -2,-0.5 -r 0.0010 -n 200 -d 1920,-1080 -o image.bmp -C const char* help_messsage = "Help Message\n\n" "Usage:\n" " ./tricorn [OPTIONS]\n\n" diff --git a/Implementierung/tricorn_V3.c b/Implementierung/tricorn_V3.c index b01a7a3..1c0ede2 100644 --- a/Implementierung/tricorn_V3.c +++ b/Implementierung/tricorn_V3.c @@ -16,6 +16,7 @@ static unsigned converge(float complex position,unsigned n); void tricorn_V3(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){ // Absolute height for iteration purposes + unsigned imag_direction = height < 0 ? -1 : 1; height = height < 0 ? height*-1 : height; unsigned bytesPerColor = color ? 3 : 1; @@ -23,7 +24,7 @@ void tricorn_V3(float complex start, size_t width, ssize_t height, float res, un for(size_t i = 0; i < width; i++){ for(ssize_t j = 0; j < height; j++){ - unsigned value = converge(start + (i*res - I*j*res),n); + unsigned value = converge(start + (i*res - imag_direction*j*res),n); // Pixel value position in the output array size_t position = (j*width +i) * bytesPerColor;