added FatouComputation

git-svn-id: svn://anubis/gvsu@321 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-12-07 22:18:36 +00:00
parent ac83b40fb9
commit 1fade8b250
4 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#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;
}

View File

@ -0,0 +1,13 @@
#ifndef FATOUCOMPUTATION_H
#define FATOUCOMPUTATION_H FATOUCOMPUTATION_H
#include "Computation.h"
class FatouComputation : public Computation
{
public:
unsigned int compute(double x, double y);
};
#endif

View File

@ -5,6 +5,7 @@ LDFLAGS := `sdl-config --libs`
TARGET := mpi-fractals
OBJS := mpi-fractals.o
OBJS += NewtonComputation.o
OBJS += FatouComputation.o
all: $(TARGET)

View File

@ -9,6 +9,7 @@
#include <iostream>
#include "Computation.h"
#include "NewtonComputation.h"
#include "FatouComputation.h"
using namespace std;
/* a "task" will be processing TASK_SIZE pixels */
@ -63,6 +64,15 @@ int main(int argc, char * argv[])
case 0:
default:
computation = new NewtonComputation();
x_center = 0.0;
y_center = 0.0;
zoom = 2.0 / width;
break;
case 1:
computation = new FatouComputation();
x_center = 3.001;
y_center = 0.075975;
zoom = 2.0 / width;
break;
}