Fixed tricorn_V3.c to adjust mathematical direction based on height sign
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user