Created
August 16, 2017 22:58
-
-
Save sleibrock/13cd2f8cf155ebdc82f9914ee8e58ca0 to your computer and use it in GitHub Desktop.
Basic Mandelbrot Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char iter; | |
for(unsigned int y=0; y < h; y++) | |
{ | |
for(unsigned int x=0; x < w; x++) | |
{ | |
iter = 0; | |
z_re = 0; | |
z_im = 0; | |
z_re2 = 0; | |
z_im2 = 0; | |
while(z_re2 + z_im2 < THRESHOLD && iter++ < MAX_ITERS) | |
{ | |
z_re2 = z_re * z_re; | |
z_im2 = z_im * z_im; | |
z_im = (2.0 * z_re * z_im) + c_im; | |
z_re = z_re2 - z_im2 + c_re; | |
} | |
c_re += inc_re; | |
ofs << iter << iter << iter; | |
} | |
c_re = init_re; | |
c_im += inc_im; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment