Created
February 25, 2020 01:22
-
-
Save cosinekitty/2e3acc5b83c0c8596254897ed8233b9f to your computer and use it in GitHub Desktop.
C++ implementation of the Mandelbrot Set function
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
static int Mandelbrot(double cr, double ci, int limit) | |
{ | |
int count = 0; | |
double zr = 0.0; | |
double zi = 0.0; | |
double zr2 = 0.0; | |
double zi2 = 0.0; | |
while ((count < limit) && (zr2 + zi2 < 4.001)) | |
{ | |
double tzi = 2.0*zr*zi + ci; | |
zr = zr2 - zi2 + cr; | |
zi = tzi; | |
zr2 = zr*zr; | |
zi2 = zi*zi; | |
++count; | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment