added FatouComputation
git-svn-id: svn://anubis/gvsu@321 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
ac83b40fb9
commit
1fade8b250
25
cs677/final/FatouComputation.cc
Normal file
25
cs677/final/FatouComputation.cc
Normal 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;
|
||||
}
|
13
cs677/final/FatouComputation.h
Normal file
13
cs677/final/FatouComputation.h
Normal 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
|
@ -5,6 +5,7 @@ LDFLAGS := `sdl-config --libs`
|
||||
TARGET := mpi-fractals
|
||||
OBJS := mpi-fractals.o
|
||||
OBJS += NewtonComputation.o
|
||||
OBJS += FatouComputation.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user