Files
GRA-Project/Implementierung/converge_helper.h
T

24 lines
612 B
C

#ifndef CONVERGE_HELPER_H
#define CONVERGE_HELPER_H
static inline unsigned converge(float c_real, float c_imag, unsigned n) {
float real = 0.0f;
float imag = 0.0f;
for (unsigned i = 0; i < n; i++) {
float real2 = real * real;
float imag2 = imag * imag;
// If the pixel has diverged calculate the value and return it
if (real2 + imag2 > 4.0f) {
return 255 - 4 * (i % 64);
}
// Calculate imaginary and real parts separately
imag = -2.0f * real * imag + c_imag;
real = real2 - imag2 + c_real;
}
return 0;
}
#endif