gvsu/cs677/final/FatouComputation.cc
josh 1fade8b250 added FatouComputation
git-svn-id: svn://anubis/gvsu@321 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-12-07 22:18:36 +00:00

26 lines
633 B
C++

#include <math.h> /* sqrt() */
#include <complex.h> /* complex, I, creal(), cimag() */
#include "FatouComputation.h"
#define LEEWAY 0.001
#define ITERATIONS 100
#define CLOSE_ENOUGH(z, x, y) \
(fabs(creal(z) - (x)) < LEEWAY && fabs(cimag(z) - (y)) < LEEWAY)
unsigned int FatouComputation::compute(double x, double y)
{
double complex z = 0.1;
double complex p = x + I * y;
for (int iter = 0; iter < ITERATIONS; iter++)
{
z = p * (1 - z) * z;
if (cabs(z) > 2.0)
{
return 0xFF * ((double) iter / (double) ITERATIONS);
}
}
return 0;
}