replaced spaces with tabs
This commit is contained in:
parent
0ada7e07d2
commit
49b3649891
30 changed files with 951 additions and 951 deletions
112
Attractor.cpp
112
Attractor.cpp
|
@ -14,9 +14,9 @@ Attractor::Attractor(const char* const fileName) {
|
||||||
// opening file
|
// opening file
|
||||||
std::cout << "Reading file " << fileName << "..." << std::endl;
|
std::cout << "Reading file " << fileName << "..." << std::endl;
|
||||||
|
|
||||||
stfu::node system;
|
stfu::node system;
|
||||||
system.read(fileName);
|
system.read(fileName);
|
||||||
stfu::node attractor = system.getChild("AttractorKernel");
|
stfu::node attractor = system.getChild("AttractorKernel");
|
||||||
|
|
||||||
myAttractor = AttractorKernel::createAttractorKernel(attractor);
|
myAttractor = AttractorKernel::createAttractorKernel(attractor);
|
||||||
}
|
}
|
||||||
|
@ -28,81 +28,81 @@ Attractor::~Attractor(){
|
||||||
|
|
||||||
// this should probably done in the projector section
|
// this should probably done in the projector section
|
||||||
void Attractor::init_range() {
|
void Attractor::init_range() {
|
||||||
// stabilize attractor
|
// stabilize attractor
|
||||||
for ( unsigned int i = 0; i < 100000; i++ ) {
|
for ( unsigned int i = 0; i < 100000; i++ ) {
|
||||||
iterate();
|
iterate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize projectors with dimension and first point
|
// initialize projectors with dimension and first point
|
||||||
const unsigned int dimension = myAttractor->getDimension();
|
const unsigned int dimension = myAttractor->getDimension();
|
||||||
const double * point = myAttractor->vector();
|
const double * point = myAttractor->vector();
|
||||||
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
||||||
(*it)->extern_dim = dimension;
|
(*it)->extern_dim = dimension;
|
||||||
(*it)->intern_dim = 2;
|
(*it)->intern_dim = 2;
|
||||||
(*it)->init(point);
|
(*it)->init(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update ranges
|
// update ranges
|
||||||
for ( unsigned int i = 0; i < 100000; i++ ) {
|
for ( unsigned int i = 0; i < 100000; i++ ) {
|
||||||
iterate();
|
iterate();
|
||||||
|
|
||||||
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
||||||
(*it)->update_range(point);
|
(*it)->update_range(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
||||||
(*it)->finish_range();
|
(*it)->finish_range();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attractor::is_chaos() {
|
bool Attractor::is_chaos() {
|
||||||
/*
|
/*
|
||||||
check existence of attractor:
|
check existence of attractor:
|
||||||
Escaping
|
Escaping
|
||||||
Single point attractor
|
Single point attractor
|
||||||
Lyapunov exponent
|
Lyapunov exponent
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for ( unsigned int i = 0; i < dim; i++ ) {
|
for ( unsigned int i = 0; i < dim; i++ ) {
|
||||||
const double dist = 0; //new_point[i] - point[i];
|
const double dist = 0; //new_point[i] - point[i];
|
||||||
sum += dist*dist;
|
sum += dist*dist;
|
||||||
}
|
}
|
||||||
if ( sum >= 1.0e7 ) {
|
if ( sum >= 1.0e7 ) {
|
||||||
// big change => Escaping
|
// big change => Escaping
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( sum <= 1.0e-7 ) {
|
if ( sum <= 1.0e-7 ) {
|
||||||
// small change => singularity
|
// small change => singularity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attractor::iterate() {
|
void Attractor::iterate() {
|
||||||
(*myAttractor)();
|
(*myAttractor)();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attractor::plot() {
|
void Attractor::plot() {
|
||||||
for ( std::vector<Projector *>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
for ( std::vector<Projector *>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
|
||||||
const double * point = myAttractor->vector();
|
const double * point = myAttractor->vector();
|
||||||
(*it)->plot(point);
|
(*it)->plot(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IO & control
|
IO & control
|
||||||
*/
|
*/
|
||||||
void Attractor::output() {
|
void Attractor::output() {
|
||||||
const unsigned int dimension = myAttractor->getDimension();
|
const unsigned int dimension = myAttractor->getDimension();
|
||||||
const double * point = myAttractor->vector();
|
const double * point = myAttractor->vector();
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
std::cout << point[i] << " ";
|
std::cout << point[i] << " ";
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,22 +9,22 @@ class AttractorKernel;
|
||||||
class Attractor {
|
class Attractor {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AttractorKernel * myAttractor;
|
AttractorKernel * myAttractor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// should be private really
|
// should be private really
|
||||||
std::vector<Projector *> projectors;
|
std::vector<Projector *> projectors;
|
||||||
|
|
||||||
Attractor(const char* const filename);
|
Attractor(const char* const filename);
|
||||||
~Attractor();
|
~Attractor();
|
||||||
|
|
||||||
void init_range();
|
void init_range();
|
||||||
bool is_chaos();
|
bool is_chaos();
|
||||||
|
|
||||||
void iterate();
|
void iterate();
|
||||||
void plot();
|
void plot();
|
||||||
void output();
|
void output();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* AttractorKernel.cpp
|
* AttractorKernel.cpp
|
||||||
* AwesomeAttractor
|
* AwesomeAttractor
|
||||||
*
|
*
|
||||||
* Created by Joshua Moerman on 07-08-10.
|
* Created by Joshua Moerman on 07-08-10.
|
||||||
* Copyright 2010 Rodo. All rights reserved.
|
* Copyright 2010 Rodo. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -97,62 +97,62 @@ AttractorKernel * AttractorKernel::createAttractorKernel(stfu::node& attractor){
|
||||||
AttractorKernel * myAttractor = NULL;
|
AttractorKernel * myAttractor = NULL;
|
||||||
|
|
||||||
// reading basic stuff
|
// reading basic stuff
|
||||||
const std::string attractorType = attractor.getValue("type");
|
const std::string attractorType = attractor.getValue("type");
|
||||||
const std::string attractorDimension = attractor.getValue("dimensions");
|
const std::string attractorDimension = attractor.getValue("dimensions");
|
||||||
|
|
||||||
// for ( unsigned int i = 0; attractorType[i] != '\0'; i++ ) {
|
// for ( unsigned int i = 0; attractorType[i] != '\0'; i++ ) {
|
||||||
// attractorType[i] = tolower(attractorType[i]);
|
// attractorType[i] = tolower(attractorType[i]);
|
||||||
// }
|
// }
|
||||||
const unsigned int dimension = atoi(attractorDimension.c_str());
|
const unsigned int dimension = atoi(attractorDimension.c_str());
|
||||||
|
|
||||||
std::cout << " Formula: " << attractorType << std::endl;
|
std::cout << " Formula: " << attractorType << std::endl;
|
||||||
std::cout << " Dimensions: " << dimension << std::endl;
|
std::cout << " Dimensions: " << dimension << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// depending on type, make the formula object
|
// depending on type, make the formula object
|
||||||
if ( attractorType == "lorenz" ){
|
if ( attractorType == "lorenz" ){
|
||||||
if ( dimension == 3 ) {
|
if ( dimension == 3 ) {
|
||||||
myAttractor = new Lorenz3D();
|
myAttractor = new Lorenz3D();
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "something wrong";
|
std::cerr << "something wrong";
|
||||||
exit(37);
|
exit(37);
|
||||||
}
|
}
|
||||||
} else if ( attractorType == "polynomial" ) {
|
} else if ( attractorType == "polynomial" ) {
|
||||||
const std::string attractorOrde = attractor.getValue("orde");
|
const std::string attractorOrde = attractor.getValue("orde");
|
||||||
const unsigned int orde = atoi(attractorOrde.c_str());
|
const unsigned int orde = atoi(attractorOrde.c_str());
|
||||||
std::cout << " Orde: " << orde << std::endl;
|
std::cout << " Orde: " << orde << std::endl;
|
||||||
myAttractor = new Polynomial(dimension, orde);
|
myAttractor = new Polynomial(dimension, orde);
|
||||||
|
|
||||||
} else if ( attractorType == "polynomial a" ) {
|
} else if ( attractorType == "polynomial a" ) {
|
||||||
if ( dimension == 3 ) {
|
if ( dimension == 3 ) {
|
||||||
myAttractor = new PolynomialA3D();
|
myAttractor = new PolynomialA3D();
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "something wrong";
|
std::cerr << "something wrong";
|
||||||
exit(37);
|
exit(37);
|
||||||
}
|
}
|
||||||
} else if ( attractorType == "logistic" ) {
|
} else if ( attractorType == "logistic" ) {
|
||||||
myAttractor = new Logistic(dimension);
|
myAttractor = new Logistic(dimension);
|
||||||
} else if ( attractorType == "unravel" ) {
|
} else if ( attractorType == "unravel" ) {
|
||||||
if ( dimension == 3 ) {
|
if ( dimension == 3 ) {
|
||||||
myAttractor = new Unravel3D();
|
myAttractor = new Unravel3D();
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "something wrong";
|
std::cerr << "something wrong";
|
||||||
exit(37);
|
exit(37);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout << "'" << attractorType << "' not recognized" << std::endl;
|
std::cout << "'" << attractorType << "' not recognized" << std::endl;
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// read parameters
|
// read parameters
|
||||||
const unsigned int numberOfParameters = myAttractor->getNumberOfParameters();
|
const unsigned int numberOfParameters = myAttractor->getNumberOfParameters();
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < numberOfParameters; i++ ) {
|
for ( unsigned int i = 0; i < numberOfParameters; i++ ) {
|
||||||
stfu::node attractorParameters = attractor.getChild("parameters");
|
stfu::node attractorParameters = attractor.getChild("parameters");
|
||||||
(*myAttractor)[i] = atof(attractorParameters.getValue(i).c_str());
|
(*myAttractor)[i] = atof(attractorParameters.getValue(i).c_str());
|
||||||
std::cout << " Parameter " << i << " set to " << (*myAttractor)[i] << ", ";
|
std::cout << " Parameter " << i << " set to " << (*myAttractor)[i] << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl << " Reading file complete" << std::endl;
|
std::cout << std::endl << " Reading file complete" << std::endl;
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,17 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// parameters are stored in a array of doubles
|
// parameters are stored in a array of doubles
|
||||||
double & operator[](const unsigned int index);
|
double & operator[](const unsigned int index);
|
||||||
double const & operator[](const unsigned int index) const;
|
double const & operator[](const unsigned int index) const;
|
||||||
unsigned int getNumberOfParameters() const;
|
unsigned int getNumberOfParameters() const;
|
||||||
|
|
||||||
// iterate his formula, implemented by subclasses
|
// iterate his formula, implemented by subclasses
|
||||||
virtual void operator()() = 0;
|
virtual void operator()() = 0;
|
||||||
|
|
||||||
// getter functions for teh resulta (can't be used as setters)
|
// getter functions for teh resulta (can't be used as setters)
|
||||||
double const * vector() const;
|
double const * vector() const;
|
||||||
double const * previousVector() const;
|
double const * previousVector() const;
|
||||||
unsigned int getDimension() const;
|
unsigned int getDimension() const;
|
||||||
|
|
||||||
// dtor, should be virtual for subclasses to be deleted
|
// dtor, should be virtual for subclasses to be deleted
|
||||||
|
|
310
Canvas.cpp
310
Canvas.cpp
|
@ -10,236 +10,236 @@
|
||||||
|
|
||||||
|
|
||||||
Canvas::Canvas(unsigned int width, unsigned int height, unsigned int num_colors):
|
Canvas::Canvas(unsigned int width, unsigned int height, unsigned int num_colors):
|
||||||
dim(2), width(width), height(height), num_colors(num_colors), v(0) {
|
dim(2), width(width), height(height), num_colors(num_colors), v(0) {
|
||||||
|
|
||||||
int_array = new unsigned int[width*height*num_colors];
|
int_array = new unsigned int[width*height*num_colors];
|
||||||
size = new unsigned int[2];
|
size = new unsigned int[2];
|
||||||
size[0] = width;
|
size[0] = width;
|
||||||
size[1] = height;
|
size[1] = height;
|
||||||
|
|
||||||
assert(int_array != NULL);
|
assert(int_array != NULL);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New canvas" << endl;
|
cout << "New canvas" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::clear() {
|
void Canvas::clear() {
|
||||||
for ( unsigned int i = 0; i < width*height*num_colors; i++ ) {
|
for ( unsigned int i = 0; i < width*height*num_colors; i++ ) {
|
||||||
int_array[i] = 0;
|
int_array[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void Canvas::update_viewwindow() {
|
//void Canvas::update_viewwindow() {
|
||||||
//
|
//
|
||||||
// //width and height of attractor
|
// //width and height of attractor
|
||||||
// const double dx = xmax - xmin;
|
// const double dx = xmax - xmin;
|
||||||
// const double dy = ymax - ymin;
|
// const double dy = ymax - ymin;
|
||||||
//
|
//
|
||||||
// //fix aspect ratio
|
// //fix aspect ratio
|
||||||
// if ( dx > dy * ((float)width / height) ) {
|
// if ( dx > dy * ((float)width / height) ) {
|
||||||
// const double height2 = dx * ((float)height / width);
|
// const double height2 = dx * ((float)height / width);
|
||||||
// const double middle = 0.5 * (ymax + ymin);
|
// const double middle = 0.5 * (ymax + ymin);
|
||||||
// ymax = middle + 0.5 * height2;
|
// ymax = middle + 0.5 * height2;
|
||||||
// ymin = middle - 0.5 * height2;
|
// ymin = middle - 0.5 * height2;
|
||||||
//
|
//
|
||||||
// } else {
|
// } else {
|
||||||
// const double width2 = dy * ((float)width / height);
|
// const double width2 = dy * ((float)width / height);
|
||||||
// const double middle = 0.5 * (xmax + xmin);
|
// const double middle = 0.5 * (xmax + xmin);
|
||||||
// xmax = middle + 0.5 * width2;
|
// xmax = middle + 0.5 * width2;
|
||||||
// xmin = middle - 0.5 * width2;
|
// xmin = middle - 0.5 * width2;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //add a 4% marge
|
// //add a 4% marge
|
||||||
// xmin -= 0.02 * dx;
|
// xmin -= 0.02 * dx;
|
||||||
// xmax += 0.02 * dx;
|
// xmax += 0.02 * dx;
|
||||||
// ymin -= 0.02 * dy;
|
// ymin -= 0.02 * dy;
|
||||||
// ymax += 0.02 * dy;
|
// ymax += 0.02 * dy;
|
||||||
//
|
//
|
||||||
// //constants for speed
|
// //constants for speed
|
||||||
// constant1 = width / (xmax - xmin);
|
// constant1 = width / (xmax - xmin);
|
||||||
// constant2 = height / (ymax - ymin);
|
// constant2 = height / (ymax - ymin);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void Canvas::plot(double x, double y) {
|
void Canvas::plot(double x, double y) {
|
||||||
// gets x and y coordinate
|
// gets x and y coordinate
|
||||||
// ranges [-1, 1] and [-1, 1]
|
// ranges [-1, 1] and [-1, 1]
|
||||||
// so how to do the aspect shiz, i don't know
|
// so how to do the aspect shiz, i don't know
|
||||||
const unsigned int x_int = x*width + width*.5;
|
const unsigned int x_int = x*width + width*.5;
|
||||||
const unsigned int y_int = y*width + height*.5;
|
const unsigned int y_int = y*width + height*.5;
|
||||||
const unsigned int index = x_int + width * y_int;
|
const unsigned int index = x_int + width * y_int;
|
||||||
|
|
||||||
if(x_int < width && y_int < height) {
|
if(x_int < width && y_int < height) {
|
||||||
int_array[index]++;
|
int_array[index]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::plot(double x, double y, unsigned int c) {
|
void Canvas::plot(double x, double y, unsigned int c) {
|
||||||
// same as plot(double x, double y)
|
// same as plot(double x, double y)
|
||||||
// now with color control
|
// now with color control
|
||||||
const unsigned int x_int = x*width + width*.5;
|
const unsigned int x_int = x*width + width*.5;
|
||||||
const unsigned int y_int = y*width + height*.5;
|
const unsigned int y_int = y*width + height*.5;
|
||||||
const unsigned int index = x_int + width * y_int + width*height*c;
|
const unsigned int index = x_int + width * y_int + width*height*c;
|
||||||
|
|
||||||
if(x_int < width && y_int < height) {
|
if(x_int < width && y_int < height) {
|
||||||
int_array[index]++;
|
int_array[index]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::plot(double x, double y, unsigned int c, double intensity) {
|
void Canvas::plot(double x, double y, unsigned int c, double intensity) {
|
||||||
// same as plot(double x, double y, unsigned int c)
|
// same as plot(double x, double y, unsigned int c)
|
||||||
// but now uses the float array (not yet implemented
|
// but now uses the float array (not yet implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
I/O functions
|
I/O functions
|
||||||
*/
|
*/
|
||||||
void Canvas::output() {
|
void Canvas::output() {
|
||||||
std::cout << "Canvas: " << std::endl;
|
std::cout << "Canvas: " << std::endl;
|
||||||
std::cout << "Dimensions: " << width << " x " << height << " x " << num_colors << std::endl;
|
std::cout << "Dimensions: " << width << " x " << height << " x " << num_colors << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::output_file(const char * filename){
|
void Canvas::output_file(const char * filename){
|
||||||
unsigned int * max_int = new unsigned int[num_colors];
|
unsigned int * max_int = new unsigned int[num_colors];
|
||||||
double * power = new double[num_colors];
|
double * power = new double[num_colors];
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
||||||
max_int[i] = 0;
|
max_int[i] = 0;
|
||||||
double cumulative = 0;
|
double cumulative = 0;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
|
|
||||||
for ( unsigned int j = 0; j < width*height; j++) {
|
for ( unsigned int j = 0; j < width*height; j++) {
|
||||||
if ( max_int[i] < int_array[j+i*width*height] ) {
|
if ( max_int[i] < int_array[j+i*width*height] ) {
|
||||||
max_int[i] = int_array[j+i*width*height];
|
max_int[i] = int_array[j+i*width*height];
|
||||||
}
|
}
|
||||||
if ( int_array[j+i*width*height] ) {
|
if ( int_array[j+i*width*height] ) {
|
||||||
cumulative += int_array[j+i*width*height];
|
cumulative += int_array[j+i*width*height];
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( n > 100 ) {
|
if ( n > 100 ) {
|
||||||
const double average = cumulative / (double)n;
|
const double average = cumulative / (double)n;
|
||||||
power[i] = -2.5/log(average/(double)max_int[i]);
|
power[i] = -2.5/log(average/(double)max_int[i]);
|
||||||
if ( power[i] < 0 )
|
if ( power[i] < 0 )
|
||||||
power[i] = 1;
|
power[i] = 1;
|
||||||
} else {
|
} else {
|
||||||
power[i] = 1;
|
power[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( n <= 10 ) {
|
if ( n <= 10 ) {
|
||||||
std::cout << "not enough data" << std::endl;
|
std::cout << "not enough data" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double vibrancy = 2.0;
|
const double vibrancy = 2.0;
|
||||||
double averagePower = 0;
|
double averagePower = 0;
|
||||||
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
||||||
averagePower += power[i];
|
averagePower += power[i];
|
||||||
}
|
}
|
||||||
averagePower /= (double)num_colors;
|
averagePower /= (double)num_colors;
|
||||||
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
for ( unsigned int i = 0; i < num_colors; i++ ) {
|
||||||
power[i] = vibrancy*power[i] + (1.0 - vibrancy)*averagePower;
|
power[i] = vibrancy*power[i] + (1.0 - vibrancy)*averagePower;
|
||||||
}
|
}
|
||||||
|
|
||||||
pngwriter * pngFile = new pngwriter(width, height, 0.0, filename);
|
pngwriter * pngFile = new pngwriter(width, height, 0.0, filename);
|
||||||
pngFile->setcompressionlevel(9);
|
pngFile->setcompressionlevel(9);
|
||||||
pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
||||||
|
|
||||||
for ( unsigned int x = 0; x < width; x++ ) {
|
for ( unsigned int x = 0; x < width; x++ ) {
|
||||||
for ( unsigned int y = 0; y < height; y++ ) {
|
for ( unsigned int y = 0; y < height; y++ ) {
|
||||||
double r = 0.0;
|
double r = 0.0;
|
||||||
double g = 0.0;
|
double g = 0.0;
|
||||||
double b = 0.0;
|
double b = 0.0;
|
||||||
for ( unsigned int c = 0; c < num_colors; c++ ) {
|
for ( unsigned int c = 0; c < num_colors; c++ ) {
|
||||||
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
||||||
switch(c){
|
switch(c){
|
||||||
case 0: {
|
case 0: {
|
||||||
r = (pow(norm_value, power[c]))*3.5;
|
r = (pow(norm_value, power[c]))*3.5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
g = (pow(norm_value, power[c]))*3.0;
|
g = (pow(norm_value, power[c]))*3.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
b = (pow(norm_value, power[c]))*3.0;
|
b = (pow(norm_value, power[c]))*3.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//pngwriter clips values for me
|
//pngwriter clips values for me
|
||||||
pngFile->plot(x, y, r, g, b);
|
pngFile->plot(x, y, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete[] max_int;
|
delete[] max_int;
|
||||||
delete[] power;
|
delete[] power;
|
||||||
|
|
||||||
std::cout << "ready for writing file i suppose: " << filename << std::endl;
|
std::cout << "ready for writing file i suppose: " << filename << std::endl;
|
||||||
|
|
||||||
std::ofstream file(filename);
|
std::ofstream file(filename);
|
||||||
if ( !file ) {
|
if ( !file ) {
|
||||||
std::cout << "jij hebt pech, geen png voor jou" << std::endl;
|
std::cout << "jij hebt pech, geen png voor jou" << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << filename << std::endl;
|
std::cout << filename << std::endl;
|
||||||
|
|
||||||
|
|
||||||
pngFile->close();
|
pngFile->close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::output_file(){
|
void Canvas::output_file(){
|
||||||
char filename[50];
|
char filename[50];
|
||||||
time_t t = time(0);
|
time_t t = time(0);
|
||||||
struct tm* lt = localtime(&t);
|
struct tm* lt = localtime(&t);
|
||||||
int r = rand() % 10;
|
int r = rand() % 10;
|
||||||
|
|
||||||
sprintf(filename, "render/attractor_%04d-%02d-%02d_%02d-%02d-%02d-%01d.png", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
|
sprintf(filename, "render/attractor_%04d-%02d-%02d_%02d-%02d-%02d-%01d.png", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
|
||||||
|
|
||||||
output_file(filename);
|
output_file(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Canvas::output_raw(const char * filename){
|
void Canvas::output_raw(const char * filename){
|
||||||
|
|
||||||
std::ofstream outfile (filename, std::ofstream::binary);
|
std::ofstream outfile (filename, std::ofstream::binary);
|
||||||
|
|
||||||
outfile.write(reinterpret_cast<char*>(int_array), sizeof(unsigned int)*width*height*num_colors);
|
outfile.write(reinterpret_cast<char*>(int_array), sizeof(unsigned int)*width*height*num_colors);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::output_raw(){
|
void Canvas::output_raw(){
|
||||||
char filename[52];
|
char filename[52];
|
||||||
time_t t = time(0);
|
time_t t = time(0);
|
||||||
struct tm* lt = localtime(&t);
|
struct tm* lt = localtime(&t);
|
||||||
int r = rand() % 10;
|
int r = rand() % 10;
|
||||||
|
|
||||||
sprintf(filename, "render/canv%dx%d_%04d-%02d-%02d_%02d-%02d-%02d-%01d.canv", width, height, lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
|
sprintf(filename, "render/canv%dx%d_%04d-%02d-%02d_%02d-%02d-%02d-%01d.canv", width, height, lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
|
||||||
|
|
||||||
output_raw(filename);
|
output_raw(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::input_raw(const char * filename){
|
void Canvas::input_raw(const char * filename){
|
||||||
std::ifstream infile(filename, std::ifstream::binary);
|
std::ifstream infile(filename, std::ifstream::binary);
|
||||||
|
|
||||||
if ( ! infile ) {
|
if ( ! infile ) {
|
||||||
std::cout << "poep" << std::endl;
|
std::cout << "poep" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile.seekg (0, std::ios::end);
|
infile.seekg (0, std::ios::end);
|
||||||
int length = infile.tellg();
|
int length = infile.tellg();
|
||||||
infile.seekg (0, std::ios::beg);
|
infile.seekg (0, std::ios::beg);
|
||||||
|
|
||||||
std::cout << "length: " << length << " =? " << static_cast<int>(width*height*num_colors*sizeof(unsigned int)) << std::endl;
|
std::cout << "length: " << length << " =? " << static_cast<int>(width*height*num_colors*sizeof(unsigned int)) << std::endl;
|
||||||
|
|
||||||
infile.read (reinterpret_cast<char*>(int_array), sizeof (unsigned int)*width*height*num_colors);
|
infile.read (reinterpret_cast<char*>(int_array), sizeof (unsigned int)*width*height*num_colors);
|
||||||
}
|
}
|
||||||
|
|
46
Canvas.hpp
46
Canvas.hpp
|
@ -9,39 +9,39 @@
|
||||||
// TODO : Canvas class abstraheren (zodat er makkelijk verschillende soorten canvae gemaakt kunnen worden)
|
// TODO : Canvas class abstraheren (zodat er makkelijk verschillende soorten canvae gemaakt kunnen worden)
|
||||||
|
|
||||||
class Canvas{
|
class Canvas{
|
||||||
friend class Projector;
|
friend class Projector;
|
||||||
|
|
||||||
unsigned int dim;
|
unsigned int dim;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int num_colors;
|
unsigned int num_colors;
|
||||||
|
|
||||||
unsigned int * size;
|
unsigned int * size;
|
||||||
|
|
||||||
unsigned int * int_array;
|
unsigned int * int_array;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
double v;
|
double v;
|
||||||
|
|
||||||
Canvas(unsigned int width, unsigned int height, unsigned int num_colors = 1);
|
Canvas(unsigned int width, unsigned int height, unsigned int num_colors = 1);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void plot(double x, double y);
|
void plot(double x, double y);
|
||||||
void plot(double x, double y, unsigned int c);
|
void plot(double x, double y, unsigned int c);
|
||||||
// TODO : make double array in canvas (ander soort canvas)
|
// TODO : make double array in canvas (ander soort canvas)
|
||||||
// TODO : subpixel sampling (anders soort canvas)
|
// TODO : subpixel sampling (anders soort canvas)
|
||||||
void plot(double x, double y, unsigned int c, double intensity);
|
void plot(double x, double y, unsigned int c, double intensity);
|
||||||
|
|
||||||
void output();
|
void output();
|
||||||
//void output(Vector& point);
|
//void output(Vector& point);
|
||||||
|
|
||||||
void output_file(const char * filename);
|
void output_file(const char * filename);
|
||||||
void output_file();
|
void output_file();
|
||||||
void output_raw(const char * filename);
|
void output_raw(const char * filename);
|
||||||
void output_raw();
|
void output_raw();
|
||||||
void input_raw(const char * filename);
|
void input_raw(const char * filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
102
Parameters.cpp
102
Parameters.cpp
|
@ -5,106 +5,106 @@ using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Parameters::Parameters(unsigned int num_parameters, float default_val):
|
Parameters::Parameters(unsigned int num_parameters, float default_val):
|
||||||
num_parameters(num_parameters) {
|
num_parameters(num_parameters) {
|
||||||
begin = new (nothrow) Vector(num_parameters, default_val);
|
begin = new (nothrow) Vector(num_parameters, default_val);
|
||||||
eind = new (nothrow) Vector(num_parameters, default_val);
|
eind = new (nothrow) Vector(num_parameters, default_val);
|
||||||
interpolated = new (nothrow) Vector(num_parameters, default_val);
|
interpolated = new (nothrow) Vector(num_parameters, default_val);
|
||||||
// *interpolated = *begin
|
// *interpolated = *begin
|
||||||
|
|
||||||
check_pointers();
|
check_pointers();
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New Parameters with one default val:" << endl << *this << endl;
|
cout << "New Parameters with one default val:" << endl << *this << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Parameters::Parameters(unsigned int num_parameters, float default_val1, float default_val2):
|
/*Parameters::Parameters(unsigned int num_parameters, float default_val1, float default_val2):
|
||||||
num_parameters(num_parameters) {
|
num_parameters(num_parameters) {
|
||||||
begin = new (nothrow) Vector(num_parameters, default_val1);
|
begin = new (nothrow) Vector(num_parameters, default_val1);
|
||||||
eind = new (nothrow) Vector(num_parameters, default_val2);
|
eind = new (nothrow) Vector(num_parameters, default_val2);
|
||||||
interpolated = new (nothrow) Vector(num_parameters, default_val1);
|
interpolated = new (nothrow) Vector(num_parameters, default_val1);
|
||||||
// *interpolated = *begin
|
// *interpolated = *begin
|
||||||
|
|
||||||
check_pointers();
|
check_pointers();
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New Parameters with two default vals:" << endl << *this << endl;
|
cout << "New Parameters with two default vals:" << endl << *this << endl;
|
||||||
#endif
|
#endif
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Parameters::~Parameters() {
|
Parameters::~Parameters() {
|
||||||
delete begin;
|
delete begin;
|
||||||
delete eind;
|
delete eind;
|
||||||
delete interpolated;
|
delete interpolated;
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "Parameters deleted" << endl;
|
cout << "Parameters deleted" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parameters::check_pointers() {
|
void Parameters::check_pointers() {
|
||||||
assert(begin != NULL);
|
assert(begin != NULL);
|
||||||
assert(eind != NULL);
|
assert(eind != NULL);
|
||||||
assert(interpolated != NULL);
|
assert(interpolated != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parameters::set(unsigned int parameter, float val1, float val2) {
|
void Parameters::set(unsigned int parameter, float val1, float val2) {
|
||||||
assert(parameter < num_parameters);
|
assert(parameter < num_parameters);
|
||||||
|
|
||||||
begin->coordinates[parameter] = val1;
|
begin->coordinates[parameter] = val1;
|
||||||
eind->coordinates[parameter] = val2;
|
eind->coordinates[parameter] = val2;
|
||||||
interpolated->coordinates[parameter] = val1;
|
interpolated->coordinates[parameter] = val1;
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "Parameter " << parameter << " set to: " << val1 << " - " << val2 << endl;
|
cout << "Parameter " << parameter << " set to: " << val1 << " - " << val2 << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parameters::set(unsigned int parameter, float val) {
|
void Parameters::set(unsigned int parameter, float val) {
|
||||||
assert(parameter < num_parameters);
|
assert(parameter < num_parameters);
|
||||||
|
|
||||||
begin->coordinates[parameter] = val;
|
begin->coordinates[parameter] = val;
|
||||||
eind->coordinates[parameter] = val;
|
eind->coordinates[parameter] = val;
|
||||||
interpolated->coordinates[parameter] = val;
|
interpolated->coordinates[parameter] = val;
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "Parameter " << parameter << " set to: " << val << endl;
|
cout << "Parameter " << parameter << " set to: " << val << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float Parameters::get(unsigned int parameter) {
|
float Parameters::get(unsigned int parameter) {
|
||||||
assert(parameter < num_parameters);
|
assert(parameter < num_parameters);
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "Asked for parameter " << parameter << " with value:" << interpolated->coordinates[parameter] << endl;
|
cout << "Asked for parameter " << parameter << " with value:" << interpolated->coordinates[parameter] << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return interpolated->coordinates[parameter];
|
return interpolated->coordinates[parameter];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parameters::interpolate(float time) {
|
void Parameters::interpolate(float time) {
|
||||||
/*
|
/*
|
||||||
Dit is mogelijk met vector rekenen:
|
Dit is mogelijk met vector rekenen:
|
||||||
(*interpolated) = (*begin) * ( 1.0 - time ) + (*eind) * time;
|
(*interpolated) = (*begin) * ( 1.0 - time ) + (*eind) * time;
|
||||||
Maar we doen het per element, zodat we simpelere code hebben,
|
Maar we doen het per element, zodat we simpelere code hebben,
|
||||||
geen vectoren hoeven te returnen en makkelijker kunnen optimaliseren
|
geen vectoren hoeven te returnen en makkelijker kunnen optimaliseren
|
||||||
*/
|
*/
|
||||||
const float invtime = 1.0 - time;
|
const float invtime = 1.0 - time;
|
||||||
for ( unsigned int i = 0; i < num_parameters; i++ ) {
|
for ( unsigned int i = 0; i < num_parameters; i++ ) {
|
||||||
interpolated->coordinates[i] = invtime * begin->coordinates[i] + time * eind->coordinates[i];
|
interpolated->coordinates[i] = invtime * begin->coordinates[i] + time * eind->coordinates[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "interpolate() result" << endl << *interpolated << endl;
|
cout << "interpolate() result" << endl << *interpolated << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream& os, const Parameters& param) {
|
ostream& operator<<(ostream& os, const Parameters& param) {
|
||||||
os << param.num_parameters << endl;
|
os << param.num_parameters << endl;
|
||||||
os << "Begin:" << endl << *param.begin << endl;
|
os << "Begin:" << endl << *param.begin << endl;
|
||||||
os << "Eind:" << endl << *param.eind << endl;
|
os << "Eind:" << endl << *param.eind << endl;
|
||||||
os << "Interpolated:" << endl << *param.interpolated << endl;
|
os << "Interpolated:" << endl << *param.interpolated << endl;
|
||||||
os <<endl;
|
os <<endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,30 +5,30 @@
|
||||||
|
|
||||||
class Parameters {
|
class Parameters {
|
||||||
|
|
||||||
Vector * begin;
|
Vector * begin;
|
||||||
Vector * eind;
|
Vector * eind;
|
||||||
Vector * interpolated;
|
Vector * interpolated;
|
||||||
|
|
||||||
void check_pointers();
|
void check_pointers();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for checks and assertions
|
// for checks and assertions
|
||||||
unsigned int num_parameters;
|
unsigned int num_parameters;
|
||||||
|
|
||||||
Parameters(unsigned int num_parameters, float default_val = 0.0);
|
Parameters(unsigned int num_parameters, float default_val = 0.0);
|
||||||
//Parameters(unsigned int num_parameters, float default_val1, float default_val2);
|
//Parameters(unsigned int num_parameters, float default_val1, float default_val2);
|
||||||
~Parameters();
|
~Parameters();
|
||||||
|
|
||||||
void set(unsigned int parameter, float val1, float val2);
|
void set(unsigned int parameter, float val1, float val2);
|
||||||
void set(unsigned int parameter, float val);
|
void set(unsigned int parameter, float val);
|
||||||
float get(unsigned int parameter);
|
float get(unsigned int parameter);
|
||||||
|
|
||||||
void interpolate(float time);
|
void interpolate(float time);
|
||||||
|
|
||||||
// output operator
|
// output operator
|
||||||
friend ostream& operator<<(ostream& os, const Parameters& param);
|
friend ostream& operator<<(ostream& os, const Parameters& param);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARAMETER_HPP
|
#endif // PARAMETER_HPP
|
||||||
|
|
118
Projector.cpp
118
Projector.cpp
|
@ -7,103 +7,103 @@
|
||||||
#include "myMath.hpp"
|
#include "myMath.hpp"
|
||||||
|
|
||||||
void Projector::init(const double * point) {
|
void Projector::init(const double * point) {
|
||||||
init_vector();
|
init_vector();
|
||||||
|
|
||||||
project(point);
|
project(point);
|
||||||
init_range();
|
init_range();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projector::init_vector() {
|
void Projector::init_vector() {
|
||||||
project_point = new double[intern_dim];
|
project_point = new double[intern_dim];
|
||||||
offset = new double[intern_dim];
|
offset = new double[intern_dim];
|
||||||
|
|
||||||
assert(project_point != NULL);
|
assert(project_point != NULL);
|
||||||
assert(offset != NULL);
|
assert(offset != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projector::init_range() {
|
void Projector::init_range() {
|
||||||
range_min = new double[intern_dim];
|
range_min = new double[intern_dim];
|
||||||
range_max = new double[intern_dim];
|
range_max = new double[intern_dim];
|
||||||
|
|
||||||
assert(range_min != NULL);
|
assert(range_min != NULL);
|
||||||
assert(range_max != NULL);
|
assert(range_max != NULL);
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
range_min[i] = range_max[i] = project_point[i];
|
range_min[i] = range_max[i] = project_point[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projector::update_range(const double * point) {
|
void Projector::update_range(const double * point) {
|
||||||
project(point);
|
project(point);
|
||||||
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
if ( project_point[i] < range_min[i] ) {
|
if ( project_point[i] < range_min[i] ) {
|
||||||
range_min[i] = project_point[i];
|
range_min[i] = project_point[i];
|
||||||
} else if ( project_point[i] > range_max[i] ) {
|
} else if ( project_point[i] > range_max[i] ) {
|
||||||
range_max[i] = project_point[i];
|
range_max[i] = project_point[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Projector::finish_range() {
|
void Projector::finish_range() {
|
||||||
// double max_dist = 0.0;
|
// double max_dist = 0.0;
|
||||||
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
// const double dist = range_max[i] - range_min[i];
|
// const double dist = range_max[i] - range_min[i];
|
||||||
// if ( dist > max_dist )
|
// if ( dist > max_dist )
|
||||||
// max_dist = dist;
|
// max_dist = dist;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// factor = 0.9/max_dist;
|
// factor = 0.9/max_dist;
|
||||||
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
// offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
|
// offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
factor = canvas->size[0] / (range_max[0] - range_min[0]);
|
factor = canvas->size[0] / (range_max[0] - range_min[0]);
|
||||||
unsigned int teh_size = canvas->size[0];
|
unsigned int teh_size = canvas->size[0];
|
||||||
for ( unsigned int i = 1; i < intern_dim; i++ ) {
|
for ( unsigned int i = 1; i < intern_dim; i++ ) {
|
||||||
double dist = range_max[i] - range_min[i];
|
double dist = range_max[i] - range_min[i];
|
||||||
if ( factor * dist > (double)canvas->size[i] ) {
|
if ( factor * dist > (double)canvas->size[i] ) {
|
||||||
factor = (double)canvas->size[i] / dist;
|
factor = (double)canvas->size[i] / dist;
|
||||||
//teh_size = canvas->size[i];
|
//teh_size = canvas->size[i];
|
||||||
std::cout << "crap for dim" << i << std::endl;
|
std::cout << "crap for dim" << i << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
factor /= (double)teh_size;
|
factor /= (double)teh_size;
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
|
offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Projector::project(const double * point) {
|
void Projector::project(const double * point) {
|
||||||
assert(extern_dim >= 2);
|
assert(extern_dim >= 2);
|
||||||
project_point[0] = point[0];
|
project_point[0] = point[0];
|
||||||
project_point[1] = point[1];
|
project_point[1] = point[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Projector::plot(const double * point) {
|
void Projector::plot(const double * point) {
|
||||||
project(point);
|
project(point);
|
||||||
|
|
||||||
const double x = project_point[0]*factor + offset[0];
|
const double x = project_point[0]*factor + offset[0];
|
||||||
const double y = project_point[1]*factor + offset[1];
|
const double y = project_point[1]*factor + offset[1];
|
||||||
|
|
||||||
//cout << x << ", " << y << endl;
|
//cout << x << ", " << y << endl;
|
||||||
|
|
||||||
canvas->plot(x, y);
|
canvas->plot(x, y);
|
||||||
if ( even(point[2]*17) )
|
if ( even(point[2]*17) )
|
||||||
canvas->plot(x, y, 1);
|
canvas->plot(x, y, 1);
|
||||||
if ( even(point[2]*17+0.6) )
|
if ( even(point[2]*17+0.6) )
|
||||||
canvas->plot(x, y, 2);
|
canvas->plot(x, y, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Projector::output(){
|
void Projector::output(){
|
||||||
std::cout << "Projector properties: " << std::endl;
|
std::cout << "Projector properties: " << std::endl;
|
||||||
std::cout << " factor: " << factor << std::endl;
|
std::cout << " factor: " << factor << std::endl;
|
||||||
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
for ( unsigned int i = 0; i < intern_dim; i++ ) {
|
||||||
std::cout << " dimension " << i << ": offset: " << offset[i] << ", range: [" << range_min[i] << ", " << range_max[i] << "]" << std::endl;
|
std::cout << " dimension " << i << ": offset: " << offset[i] << ", range: [" << range_min[i] << ", " << range_max[i] << "]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,37 +4,37 @@
|
||||||
class Canvas;
|
class Canvas;
|
||||||
|
|
||||||
class Projector{
|
class Projector{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
unsigned int extern_dim;
|
unsigned int extern_dim;
|
||||||
unsigned int intern_dim;
|
unsigned int intern_dim;
|
||||||
|
|
||||||
Canvas * canvas;
|
Canvas * canvas;
|
||||||
double * project_point;
|
double * project_point;
|
||||||
|
|
||||||
double * range_min;
|
double * range_min;
|
||||||
double * range_max;
|
double * range_max;
|
||||||
double factor;
|
double factor;
|
||||||
double * offset;
|
double * offset;
|
||||||
|
|
||||||
void init(const double * point);
|
void init(const double * point);
|
||||||
void init_vector();
|
void init_vector();
|
||||||
void init_range();
|
void init_range();
|
||||||
void update_range(const double * point);
|
void update_range(const double * point);
|
||||||
void finish_range();
|
void finish_range();
|
||||||
|
|
||||||
|
|
||||||
// TODO : Matrix gebruiken voor lineaire afbeelding
|
// TODO : Matrix gebruiken voor lineaire afbeelding
|
||||||
// TODO : Over kleuren nadenken
|
// TODO : Over kleuren nadenken
|
||||||
/*
|
/*
|
||||||
Kleurmodi:
|
Kleurmodi:
|
||||||
-genormalizeerde coordinaten als kleurintensiteit (gebruikt fp canvas)
|
-genormalizeerde coordinaten als kleurintensiteit (gebruikt fp canvas)
|
||||||
-kleurbanden, dus met een periodieke functie (gebruikt int canvas)
|
-kleurbanden, dus met een periodieke functie (gebruikt int canvas)
|
||||||
*/
|
*/
|
||||||
void project(const double * point);
|
void project(const double * point);
|
||||||
void plot(const double * point);
|
void plot(const double * point);
|
||||||
|
|
||||||
void output();
|
void output();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROJECTOR_HPP
|
#endif // PROJECTOR_HPP
|
||||||
|
|
106
Vector.cpp
106
Vector.cpp
|
@ -4,123 +4,123 @@ using namespace std;
|
||||||
#include "Vector.hpp"
|
#include "Vector.hpp"
|
||||||
|
|
||||||
Vector::Vector():
|
Vector::Vector():
|
||||||
dimension(0) {
|
dimension(0) {
|
||||||
|
|
||||||
coordinates = new (nothrow) float[0];
|
coordinates = new (nothrow) float[0];
|
||||||
|
|
||||||
assert(coordinates != NULL);
|
assert(coordinates != NULL);
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New vector (without elements)" << endl;
|
cout << "New vector (without elements)" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector::Vector(unsigned int d):
|
Vector::Vector(unsigned int d):
|
||||||
dimension(d) {
|
dimension(d) {
|
||||||
|
|
||||||
coordinates = new (nothrow) float[dimension];
|
coordinates = new (nothrow) float[dimension];
|
||||||
|
|
||||||
assert(coordinates != NULL);
|
assert(coordinates != NULL);
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New vector:" << endl << *this << endl;
|
cout << "New vector:" << endl << *this << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector::Vector(unsigned int d, float default_val):
|
Vector::Vector(unsigned int d, float default_val):
|
||||||
dimension(d) {
|
dimension(d) {
|
||||||
|
|
||||||
coordinates = new (nothrow) float[dimension];
|
coordinates = new (nothrow) float[dimension];
|
||||||
|
|
||||||
assert(coordinates != NULL);
|
assert(coordinates != NULL);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < dimension; i++) {
|
for (unsigned int i = 0; i < dimension; i++) {
|
||||||
coordinates[i] = default_val;
|
coordinates[i] = default_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "New vector with default values:" << endl << *this << endl;
|
cout << "New vector with default values:" << endl << *this << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector::~Vector() {
|
Vector::~Vector() {
|
||||||
delete[] coordinates;
|
delete[] coordinates;
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "coordinates deleted" << endl;
|
cout << "coordinates deleted" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector& Vector::operator=(const Vector& a) {
|
Vector& Vector::operator=(const Vector& a) {
|
||||||
if ( dimension != a.dimension ) {
|
if ( dimension != a.dimension ) {
|
||||||
dimension = a.dimension;
|
dimension = a.dimension;
|
||||||
delete[] coordinates;
|
delete[] coordinates;
|
||||||
coordinates = new float[dimension];
|
coordinates = new float[dimension];
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "Dimensions were not equal, made new vector" << endl;
|
cout << "Dimensions were not equal, made new vector" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
coordinates[i] = a.coordinates[i];
|
coordinates[i] = a.coordinates[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "operator= result" << endl << *this << endl;
|
cout << "operator= result" << endl << *this << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ostream& operator<<(ostream& os, const Vector& a) {
|
ostream& operator<<(ostream& os, const Vector& a) {
|
||||||
os << a.dimension << endl;
|
os << a.dimension << endl;
|
||||||
for ( unsigned int i = 0; i < a.dimension; i++ ) {
|
for ( unsigned int i = 0; i < a.dimension; i++ ) {
|
||||||
os << a.coordinates[i] << " ";
|
os << a.coordinates[i] << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
os << endl;
|
os << endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float& Vector::operator[](const unsigned int index) {
|
float& Vector::operator[](const unsigned int index) {
|
||||||
assert(index < dimension);
|
assert(index < dimension);
|
||||||
return coordinates[index];
|
return coordinates[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// matig werkende optelling en scalaire vermenigvuldiging van vectoren
|
// matig werkende optelling en scalaire vermenigvuldiging van vectoren
|
||||||
/*
|
/*
|
||||||
Vector Vector::operator+(const Vector a) const {
|
Vector Vector::operator+(const Vector a) const {
|
||||||
if ( dimension != a.dimension ) {
|
if ( dimension != a.dimension ) {
|
||||||
cout << "WARNING: dimensions not equal in vector addition" << endl;
|
cout << "WARNING: dimensions not equal in vector addition" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
static Vector ret(dimension);
|
static Vector ret(dimension);
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
ret.coordinates[i] = coordinates[i] + a.coordinates[i];
|
ret.coordinates[i] = coordinates[i] + a.coordinates[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "operator+ result" << endl << ret << endl;
|
cout << "operator+ result" << endl << ret << endl;
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector Vector::operator*(const float a) const {
|
Vector Vector::operator*(const float a) const {
|
||||||
static Vector ret(dimension);
|
static Vector ret(dimension);
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
ret.coordinates[i] = coordinates[i] * a;
|
ret.coordinates[i] = coordinates[i] * a;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HARDDEBUG
|
#ifdef HARDDEBUG
|
||||||
cout << "operator* result" << endl << ret << endl;
|
cout << "operator* result" << endl << ret << endl;
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
34
Vector.hpp
34
Vector.hpp
|
@ -2,28 +2,28 @@
|
||||||
#define VECTOR_HPP
|
#define VECTOR_HPP
|
||||||
|
|
||||||
class Vector {
|
class Vector {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
unsigned int dimension;
|
unsigned int dimension;
|
||||||
float * coordinates;
|
float * coordinates;
|
||||||
|
|
||||||
// const, dest
|
// const, dest
|
||||||
Vector();
|
Vector();
|
||||||
Vector(unsigned int d);
|
Vector(unsigned int d);
|
||||||
Vector(unsigned int d, float default_val);
|
Vector(unsigned int d, float default_val);
|
||||||
~Vector();
|
~Vector();
|
||||||
|
|
||||||
// output operator
|
// output operator
|
||||||
friend ostream& operator<<(ostream& os, const Vector& a);
|
friend ostream& operator<<(ostream& os, const Vector& a);
|
||||||
|
|
||||||
// easy access
|
// easy access
|
||||||
float& Vector::operator[](const unsigned int index);
|
float& Vector::operator[](const unsigned int index);
|
||||||
|
|
||||||
// vector rekenen
|
// vector rekenen
|
||||||
Vector& operator=(const Vector& a);
|
Vector& operator=(const Vector& a);
|
||||||
// faaloperatoren
|
// faaloperatoren
|
||||||
// Vector operator+(const Vector a) const;
|
// Vector operator+(const Vector a) const;
|
||||||
// Vector operator*(const float a) const;
|
// Vector operator*(const float a) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,103 +3,103 @@ input: "attractor"
|
||||||
output: "png"
|
output: "png"
|
||||||
|
|
||||||
attractor: {
|
attractor: {
|
||||||
type: lorenz/unravel/polynomial/polynomial a/logistic
|
type: lorenz/unravel/polynomial/polynomial a/logistic
|
||||||
=> "polynomial"
|
=> "polynomial"
|
||||||
dimensions: most types only support 3D
|
dimensions: most types only support 3D
|
||||||
=> "3"
|
=> "3"
|
||||||
orde: "2"
|
orde: "2"
|
||||||
|
|
||||||
iterations: "1000000"
|
iterations: "1000000"
|
||||||
|
|
||||||
parameters: the variables of the attractortype
|
parameters: the variables of the attractortype
|
||||||
{
|
{
|
||||||
:"0.148"
|
:"0.148"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0.119"
|
:"0.119"
|
||||||
:"0.424"
|
:"0.424"
|
||||||
:"1.100"
|
:"1.100"
|
||||||
:"0"
|
:"0"
|
||||||
:"0.125"
|
:"0.125"
|
||||||
:"0.199"
|
:"0.199"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"-0.643"
|
:"-0.643"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"-1.120"
|
:"-1.120"
|
||||||
:"-1.188"
|
:"-1.188"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"-0.864"
|
:"-0.864"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
:"0"
|
:"0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projector: {
|
projector: {
|
||||||
type: auto center/lineair map/spherical/color projector
|
type: auto center/lineair map/spherical/color projector
|
||||||
=> "lineair map"
|
=> "lineair map"
|
||||||
|
|
||||||
domain: input of the projector, normally the attractor, but can also be a projector
|
domain: input of the projector, normally the attractor, but can also be a projector
|
||||||
=> "attractor"
|
=> "attractor"
|
||||||
domainDimension: redundant, because it knows from domain
|
domainDimension: redundant, because it knows from domain
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
codomain: output of the Projector, normally a canvas, but can also be another projector
|
codomain: output of the Projector, normally a canvas, but can also be another projector
|
||||||
=> "canvas"
|
=> "canvas"
|
||||||
codomainDimensions: redundant, because it knows from codomain
|
codomainDimensions: redundant, because it knows from codomain
|
||||||
=> "2"
|
=> "2"
|
||||||
|
|
||||||
matrix: describing the lineair map
|
matrix: describing the lineair map
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas: {
|
canvas: {
|
||||||
type: 2D image/2D slices/3D volume/2D animation
|
type: 2D image/2D slices/3D volume/2D animation
|
||||||
=> "2D image"
|
=> "2D image"
|
||||||
output: canvas/png/jpg/zip/mpg
|
output: canvas/png/jpg/zip/mpg
|
||||||
=> "png"
|
=> "png"
|
||||||
|
|
||||||
width: "6400"
|
width: "6400"
|
||||||
height: "6400"
|
height: "6400"
|
||||||
colors: "3"
|
colors: "3"
|
||||||
|
|
||||||
imageConversion: description how to show the abstract canvas classe
|
imageConversion: description how to show the abstract canvas classe
|
||||||
{
|
{
|
||||||
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
:{ :"0" :"0" :"1" }
|
:{ :"0" :"0" :"1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrancy: "0"
|
vibrancy: "0"
|
||||||
gamma: "-2.5"
|
gamma: "-2.5"
|
||||||
brightness: "3"
|
brightness: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile: png options
|
pngFile: png options
|
||||||
{
|
{
|
||||||
fileName: leave empty to autogenerate filename
|
fileName: leave empty to autogenerate filename
|
||||||
=> ""
|
=> ""
|
||||||
|
|
||||||
compression: "9"
|
compression: "9"
|
||||||
author: "Joshua Moerman"
|
author: "Joshua Moerman"
|
||||||
title: "Unravel"
|
title: "Unravel"
|
||||||
description: "A unravel-type attractor made with AwesomeAttractor"
|
description: "A unravel-type attractor made with AwesomeAttractor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,75 +3,75 @@ input: "attractor"
|
||||||
output: "png"
|
output: "png"
|
||||||
|
|
||||||
attractor: {
|
attractor: {
|
||||||
type: lorenz/unravel/polynomial/polynomial a/logistic
|
type: lorenz/unravel/polynomial/polynomial a/logistic
|
||||||
=> "Lorenz"
|
=> "Lorenz"
|
||||||
dimensions: most types only support 3D
|
dimensions: most types only support 3D
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
iterations: "1000000"
|
iterations: "1000000"
|
||||||
|
|
||||||
parameters: the variables of the attractortype
|
parameters: the variables of the attractortype
|
||||||
{
|
{
|
||||||
:"0.01"
|
:"0.01"
|
||||||
:"4.002"
|
:"4.002"
|
||||||
:"28"
|
:"28"
|
||||||
:"0.3"
|
:"0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projector: {
|
projector: {
|
||||||
type: auto center/lineair map/spherical/color projector
|
type: auto center/lineair map/spherical/color projector
|
||||||
=> "lineair map"
|
=> "lineair map"
|
||||||
|
|
||||||
domain: input of the projector, normally the attractor, but can also be a projector
|
domain: input of the projector, normally the attractor, but can also be a projector
|
||||||
=> "attractor"
|
=> "attractor"
|
||||||
domainDimension: redundant, because it knows from domain
|
domainDimension: redundant, because it knows from domain
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
codomain: output of the Projector, normally a canvas, but can also be another projector
|
codomain: output of the Projector, normally a canvas, but can also be another projector
|
||||||
=> "canvas"
|
=> "canvas"
|
||||||
codomainDimensions: redundant, because it knows from codomain
|
codomainDimensions: redundant, because it knows from codomain
|
||||||
=> "2"
|
=> "2"
|
||||||
|
|
||||||
matrix: describing the lineair map
|
matrix: describing the lineair map
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas: {
|
canvas: {
|
||||||
type: 2D image/2D slices/3D volume/2D animation
|
type: 2D image/2D slices/3D volume/2D animation
|
||||||
=> "2D image"
|
=> "2D image"
|
||||||
output: canvas/png/jpg/zip/mpg
|
output: canvas/png/jpg/zip/mpg
|
||||||
=> "png"
|
=> "png"
|
||||||
|
|
||||||
width: "6400"
|
width: "6400"
|
||||||
height: "6400"
|
height: "6400"
|
||||||
colors: "3"
|
colors: "3"
|
||||||
|
|
||||||
imageConversion: description how to show the abstract canvas classe
|
imageConversion: description how to show the abstract canvas classe
|
||||||
{
|
{
|
||||||
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
:{ :"0" :"0" :"1" }
|
:{ :"0" :"0" :"1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrancy: "0"
|
vibrancy: "0"
|
||||||
gamma: "-2.5"
|
gamma: "-2.5"
|
||||||
brightness: "3"
|
brightness: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile: png options
|
pngFile: png options
|
||||||
{
|
{
|
||||||
fileName: leave empty to autogenerate filename
|
fileName: leave empty to autogenerate filename
|
||||||
=> ""
|
=> ""
|
||||||
|
|
||||||
compression: "9"
|
compression: "9"
|
||||||
author: "Joshua Moerman"
|
author: "Joshua Moerman"
|
||||||
title: "Unravel"
|
title: "Unravel"
|
||||||
description: "A unravel-type attractor made with AwesomeAttractor"
|
description: "A unravel-type attractor made with AwesomeAttractor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,102 +3,102 @@ input: "attractor"
|
||||||
output: "png"
|
output: "png"
|
||||||
|
|
||||||
attractor: {
|
attractor: {
|
||||||
type: lorenz/unravel/polynomial/polynomial a/logistic
|
type: lorenz/unravel/polynomial/polynomial a/logistic
|
||||||
=> "polynomial"
|
=> "polynomial"
|
||||||
dimensions: most types only support 3D
|
dimensions: most types only support 3D
|
||||||
=> "3"
|
=> "3"
|
||||||
orde: "2"
|
orde: "2"
|
||||||
|
|
||||||
iterations: "1000000"
|
iterations: "1000000"
|
||||||
|
|
||||||
parameters: the variables of the attractortype
|
parameters: the variables of the attractortype
|
||||||
{
|
{
|
||||||
:"0.862"
|
:"0.862"
|
||||||
:"-1.147"
|
:"-1.147"
|
||||||
:"0.01"
|
:"0.01"
|
||||||
:"0.241"
|
:"0.241"
|
||||||
:"-0.85"
|
:"-0.85"
|
||||||
:"-0.174"
|
:"-0.174"
|
||||||
:"1.193"
|
:"1.193"
|
||||||
:"-0.572"
|
:"-0.572"
|
||||||
:"0.772"
|
:"0.772"
|
||||||
:"0.147"
|
:"0.147"
|
||||||
:"-0.049"
|
:"-0.049"
|
||||||
:"0.427"
|
:"0.427"
|
||||||
:"-0.103"
|
:"-0.103"
|
||||||
:"-0.402"
|
:"-0.402"
|
||||||
:"1.13"
|
:"1.13"
|
||||||
:"0.859"
|
:"0.859"
|
||||||
:"-0.642"
|
:"-0.642"
|
||||||
:"-0.649"
|
:"-0.649"
|
||||||
:"-1.074"
|
:"-1.074"
|
||||||
:"-0.636"
|
:"-0.636"
|
||||||
:"-0.706"
|
:"-0.706"
|
||||||
:"0.315"
|
:"0.315"
|
||||||
:"-0.125"
|
:"-0.125"
|
||||||
:"1.193"
|
:"1.193"
|
||||||
:"0.533"
|
:"0.533"
|
||||||
:"-0.091"
|
:"-0.091"
|
||||||
:"0.778"
|
:"0.778"
|
||||||
:"-1.199"
|
:"-1.199"
|
||||||
:"-0.112"
|
:"-0.112"
|
||||||
:"0.025"
|
:"0.025"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projector: {
|
projector: {
|
||||||
type: auto center/lineair map/spherical/color projector
|
type: auto center/lineair map/spherical/color projector
|
||||||
=> "lineair map"
|
=> "lineair map"
|
||||||
|
|
||||||
domain: input of the projector, normally the attractor, but can also be a projector
|
domain: input of the projector, normally the attractor, but can also be a projector
|
||||||
=> "attractor"
|
=> "attractor"
|
||||||
domainDimension: redundant, because it knows from domain
|
domainDimension: redundant, because it knows from domain
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
codomain: output of the Projector, normally a canvas, but can also be another projector
|
codomain: output of the Projector, normally a canvas, but can also be another projector
|
||||||
=> "canvas"
|
=> "canvas"
|
||||||
codomainDimensions: redundant, because it knows from codomain
|
codomainDimensions: redundant, because it knows from codomain
|
||||||
=> "2"
|
=> "2"
|
||||||
|
|
||||||
matrix: describing the lineair map
|
matrix: describing the lineair map
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas: {
|
canvas: {
|
||||||
type: 2D image/2D slices/3D volume/2D animation
|
type: 2D image/2D slices/3D volume/2D animation
|
||||||
=> "2D image"
|
=> "2D image"
|
||||||
output: canvas/png/jpg/zip/mpg
|
output: canvas/png/jpg/zip/mpg
|
||||||
=> "png"
|
=> "png"
|
||||||
|
|
||||||
width: "6400"
|
width: "6400"
|
||||||
height: "6400"
|
height: "6400"
|
||||||
colors: "3"
|
colors: "3"
|
||||||
|
|
||||||
imageConversion: description how to show the abstract canvas classe
|
imageConversion: description how to show the abstract canvas classe
|
||||||
{
|
{
|
||||||
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
:{ :"0" :"0" :"1" }
|
:{ :"0" :"0" :"1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrancy: "0"
|
vibrancy: "0"
|
||||||
gamma: "-2.5"
|
gamma: "-2.5"
|
||||||
brightness: "3"
|
brightness: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile: png options
|
pngFile: png options
|
||||||
{
|
{
|
||||||
fileName: leave empty to autogenerate filename
|
fileName: leave empty to autogenerate filename
|
||||||
=> ""
|
=> ""
|
||||||
|
|
||||||
compression: "9"
|
compression: "9"
|
||||||
author: "Joshua Moerman"
|
author: "Joshua Moerman"
|
||||||
title: "Unravel"
|
title: "Unravel"
|
||||||
description: "A unravel-type attractor made with AwesomeAttractor"
|
description: "A unravel-type attractor made with AwesomeAttractor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,78 +3,78 @@ input: "attractor"
|
||||||
output: "png"
|
output: "png"
|
||||||
|
|
||||||
attractor: {
|
attractor: {
|
||||||
type: lorenz/unravel/polynomial/polynomial a/logistic
|
type: lorenz/unravel/polynomial/polynomial a/logistic
|
||||||
=> "unravel"
|
=> "unravel"
|
||||||
dimensions: most types only support 3D
|
dimensions: most types only support 3D
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
iterations: "1000000"
|
iterations: "1000000"
|
||||||
|
|
||||||
parameters: the variables of the attractortype
|
parameters: the variables of the attractortype
|
||||||
{
|
{
|
||||||
:"-0.78"
|
:"-0.78"
|
||||||
:"2.042"
|
:"2.042"
|
||||||
:"1.22"
|
:"1.22"
|
||||||
:"-1.267"
|
:"-1.267"
|
||||||
:"1.37"
|
:"1.37"
|
||||||
:"2.3"
|
:"2.3"
|
||||||
:"-2.195"
|
:"-2.195"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projector: {
|
projector: {
|
||||||
type: auto center/lineair map/spherical/color projector
|
type: auto center/lineair map/spherical/color projector
|
||||||
=> "lineair map"
|
=> "lineair map"
|
||||||
|
|
||||||
domain: input of the projector, normally the attractor, but can also be a projector
|
domain: input of the projector, normally the attractor, but can also be a projector
|
||||||
=> "attractor"
|
=> "attractor"
|
||||||
domainDimension: redundant, because it knows from domain
|
domainDimension: redundant, because it knows from domain
|
||||||
=> "3"
|
=> "3"
|
||||||
|
|
||||||
codomain: output of the Projector, normally a canvas, but can also be another projector
|
codomain: output of the Projector, normally a canvas, but can also be another projector
|
||||||
=> "canvas"
|
=> "canvas"
|
||||||
codomainDimensions: redundant, because it knows from codomain
|
codomainDimensions: redundant, because it knows from codomain
|
||||||
=> "2"
|
=> "2"
|
||||||
|
|
||||||
matrix: describing the lineair map
|
matrix: describing the lineair map
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas: {
|
canvas: {
|
||||||
type: 2D image/2D slices/3D volume/2D animation
|
type: 2D image/2D slices/3D volume/2D animation
|
||||||
=> "2D image"
|
=> "2D image"
|
||||||
output: canvas/png/jpg/zip/mpg
|
output: canvas/png/jpg/zip/mpg
|
||||||
=> "png"
|
=> "png"
|
||||||
|
|
||||||
width: "6400"
|
width: "6400"
|
||||||
height: "6400"
|
height: "6400"
|
||||||
colors: "3"
|
colors: "3"
|
||||||
|
|
||||||
imageConversion: description how to show the abstract canvas classe
|
imageConversion: description how to show the abstract canvas classe
|
||||||
{
|
{
|
||||||
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
:{ :"0" :"0" :"1" }
|
:{ :"0" :"0" :"1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrancy: "0"
|
vibrancy: "0"
|
||||||
gamma: "-2.5"
|
gamma: "-2.5"
|
||||||
brightness: "3"
|
brightness: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile: png options
|
pngFile: png options
|
||||||
{
|
{
|
||||||
fileName: leave empty to autogenerate filename
|
fileName: leave empty to autogenerate filename
|
||||||
=> ""
|
=> ""
|
||||||
|
|
||||||
compression: "9"
|
compression: "9"
|
||||||
author: "Joshua Moerman"
|
author: "Joshua Moerman"
|
||||||
title: "Unravel"
|
title: "Unravel"
|
||||||
description: "A unravel-type attractor made with AwesomeAttractor"
|
description: "A unravel-type attractor made with AwesomeAttractor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,19 +4,19 @@ output: "Canvas"
|
||||||
iterations: "100000"
|
iterations: "100000"
|
||||||
|
|
||||||
AttractorKernel: {
|
AttractorKernel: {
|
||||||
type: "unravel"
|
type: "unravel"
|
||||||
dimensions: "3"
|
dimensions: "3"
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
{
|
{
|
||||||
:"-0.78"
|
:"-0.78"
|
||||||
:"2.042"
|
:"2.042"
|
||||||
:"1.22"
|
:"1.22"
|
||||||
:"-1.267"
|
:"-1.267"
|
||||||
:"1.37"
|
:"1.37"
|
||||||
:"2.3"
|
:"2.3"
|
||||||
:"-2.195"
|
:"-2.195"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projections: Applied in order they appear {
|
projections: Applied in order they appear {
|
||||||
|
@ -35,35 +35,35 @@ projections: Applied in order they appear {
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas: {
|
Canvas: {
|
||||||
type: "2D canvas"
|
type: "2D canvas"
|
||||||
output: "png"
|
output: "png"
|
||||||
|
|
||||||
width: "6400"
|
width: "6400"
|
||||||
height: "6400"
|
height: "6400"
|
||||||
colors: "3"
|
colors: "3"
|
||||||
|
|
||||||
imageConversion: description how to show the abstract canvas classe
|
imageConversion: description how to show the abstract canvas classe
|
||||||
{
|
{
|
||||||
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
colorMatrix: desciribing lineair map from canvas colors to RGB colorspace
|
||||||
{
|
{
|
||||||
:{ :"1" :"0" :"0" }
|
:{ :"1" :"0" :"0" }
|
||||||
:{ :"0" :"1" :"0" }
|
:{ :"0" :"1" :"0" }
|
||||||
:{ :"0" :"0" :"1" }
|
:{ :"0" :"0" :"1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrancy: "0"
|
vibrancy: "0"
|
||||||
gamma: "-2.5"
|
gamma: "-2.5"
|
||||||
exposure: "3"
|
exposure: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile: png options
|
pngFile: png options
|
||||||
{
|
{
|
||||||
fileName: leave empty to autogenerate filename
|
fileName: leave empty to autogenerate filename
|
||||||
=> ""
|
=> ""
|
||||||
|
|
||||||
compression: "9"
|
compression: "9"
|
||||||
author: "Joshua Moerman"
|
author: "Joshua Moerman"
|
||||||
title: "Unravel"
|
title: "Unravel"
|
||||||
description: "A unravel-type attractor made with AwesomeAttractor"
|
description: "A unravel-type attractor made with AwesomeAttractor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
defines.hpp
16
defines.hpp
|
@ -1,15 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
//TODO: do this with files
|
//TODO: do this with files
|
||||||
#define ATTRACTOR_FILE "attractors/testUnravel.stf"
|
#define ATTRACTOR_FILE "attractors/testUnravel.stf"
|
||||||
|
|
||||||
#ifdef UNI_BUILD
|
#ifdef UNI_BUILD
|
||||||
#warning Building for the RU, are you sure?
|
#warning Building for the RU, are you sure?
|
||||||
#define WIDTH 8000
|
#define WIDTH 8000
|
||||||
#define HEIGHT 8000
|
#define HEIGHT 8000
|
||||||
#define ITERATIONS 4200000000
|
#define ITERATIONS 4200000000
|
||||||
#else
|
#else
|
||||||
#define WIDTH 800
|
#define WIDTH 800
|
||||||
#define HEIGHT 800
|
#define HEIGHT 800
|
||||||
#define ITERATIONS 1000000
|
#define ITERATIONS 1000000
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//
|
//
|
||||||
// $filename
|
// $filename
|
||||||
// $projectname
|
// $projectname
|
||||||
//
|
//
|
||||||
// Created by Joshua moerman on $TODAY.
|
// Created by Joshua moerman on $TODAY.
|
||||||
// Copyright 2010 Joshua Moerman. All rights reserved.
|
// Copyright 2010 Joshua Moerman. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Logistic.hpp"
|
#include "Logistic.hpp"
|
||||||
|
@ -15,12 +15,12 @@
|
||||||
|
|
||||||
Logistic::Logistic():
|
Logistic::Logistic():
|
||||||
AttractorKernel(3, 3) {
|
AttractorKernel(3, 3) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Logistic::Logistic(const unsigned int dimension):
|
Logistic::Logistic(const unsigned int dimension):
|
||||||
AttractorKernel(dimension, dimension) {
|
AttractorKernel(dimension, dimension) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logistic::init() {
|
void Logistic::init() {
|
||||||
|
@ -36,8 +36,8 @@ void Logistic::init() {
|
||||||
void Logistic::operator()() {
|
void Logistic::operator()() {
|
||||||
std::swap(vectorNew, vectorOld);
|
std::swap(vectorNew, vectorOld);
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
vectorNew[i] = parameters[i]*vectorOld[i]*(1.0 - vectorOld[i]);
|
vectorNew[i] = parameters[i]*vectorOld[i]*(1.0 - vectorOld[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Logistic();
|
Logistic();
|
||||||
Logistic(const unsigned int dimension);
|
Logistic(const unsigned int dimension);
|
||||||
|
|
||||||
virtual void operator()();
|
virtual void operator()();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Lorenz3D::Lorenz3D():
|
Lorenz3D::Lorenz3D():
|
||||||
AttractorKernel(3, 4){
|
AttractorKernel(3, 4){
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lorenz3D::init() {
|
void Lorenz3D::init() {
|
||||||
|
@ -23,17 +23,17 @@ void Lorenz3D::init() {
|
||||||
void Lorenz3D::operator()() {
|
void Lorenz3D::operator()() {
|
||||||
std::swap(vectorNew, vectorOld);
|
std::swap(vectorNew, vectorOld);
|
||||||
|
|
||||||
vectorNew[0] = vectorOld[0] + parameters[0] * parameters[1] * (vectorOld[1] - vectorOld[0]);
|
vectorNew[0] = vectorOld[0] + parameters[0] * parameters[1] * (vectorOld[1] - vectorOld[0]);
|
||||||
vectorNew[1] = vectorOld[1] + parameters[0] * (vectorOld[0] * (parameters[2] - vectorOld[2]) - vectorOld[1]);
|
vectorNew[1] = vectorOld[1] + parameters[0] * (vectorOld[0] * (parameters[2] - vectorOld[2]) - vectorOld[1]);
|
||||||
vectorNew[2] = vectorOld[2] + parameters[0] * (vectorOld[0] * vectorOld[1] - parameters[3] * vectorOld[2]);
|
vectorNew[2] = vectorOld[2] + parameters[0] * (vectorOld[0] * vectorOld[1] - parameters[3] * vectorOld[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
4D:
|
4D:
|
||||||
new_point[0] = point[0] + param[0] * param[1] * (point[1] - point[0]);
|
new_point[0] = point[0] + param[0] * param[1] * (point[1] - point[0]);
|
||||||
new_point[1] = point[1] + param[0] * (point[0] * (param[2] - point[2]) - point[1] + point[3]);
|
new_point[1] = point[1] + param[0] * (point[0] * (param[2] - point[2]) - point[1] + point[3]);
|
||||||
new_point[2] = point[2] + param[0] * (point[0] * point[1] - param[3] * point[2]);
|
new_point[2] = point[2] + param[0] * (point[0] * point[1] - param[3] * point[2]);
|
||||||
new_point[3] = point[3] - param[0] * param[4] * point[0];
|
new_point[3] = point[3] - param[0] * param[4] * point[0];
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
class Lorenz3D : public AttractorKernel {
|
class Lorenz3D : public AttractorKernel {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Lorenz3D();
|
Lorenz3D();
|
||||||
|
|
||||||
virtual void operator()();
|
virtual void operator()();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//
|
//
|
||||||
// $filename
|
// $filename
|
||||||
// $projectname
|
// $projectname
|
||||||
//
|
//
|
||||||
// Created by Joshua moerman on $TODAY.
|
// Created by Joshua moerman on $TODAY.
|
||||||
// Copyright 2010 Joshua Moerman. All rights reserved.
|
// Copyright 2010 Joshua Moerman. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Polynomial.hpp"
|
#include "Polynomial.hpp"
|
||||||
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
|
|
||||||
unsigned int calculateNumberOfParameters(const unsigned int dimension, const unsigned int orde) {
|
unsigned int calculateNumberOfParameters(const unsigned int dimension, const unsigned int orde) {
|
||||||
double n_coef = orde + 1;
|
double n_coef = orde + 1;
|
||||||
for (unsigned int i = 2; i <= dimension; i++) {
|
for (unsigned int i = 2; i <= dimension; i++) {
|
||||||
n_coef = n_coef*(orde + i)/(i - 1);
|
n_coef = n_coef*(orde + i)/(i - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int output = (unsigned int) n_coef;
|
const unsigned int output = (unsigned int) n_coef;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,26 +37,26 @@ Polynomial::Polynomial(const unsigned int dimension, const unsigned int orde):
|
||||||
void Polynomial::operator()() {
|
void Polynomial::operator()() {
|
||||||
std::swap(vectorNew, vectorOld);
|
std::swap(vectorNew, vectorOld);
|
||||||
|
|
||||||
unsigned int m = 0;
|
unsigned int m = 0;
|
||||||
for ( unsigned int i = 0; i < dimension; i++ ) {
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||||||
|
|
||||||
vectorNew[i] = parameters[m];
|
vectorNew[i] = parameters[m];
|
||||||
m++;
|
m++;
|
||||||
recur(i, 0, 1, m);
|
recur(i, 0, 1, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Polynomial::recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product) {
|
void Polynomial::recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product) {
|
||||||
double product;
|
double product;
|
||||||
for (unsigned int i = prev_i; i < dimension; i++) {
|
for (unsigned int i = prev_i; i < dimension; i++) {
|
||||||
|
|
||||||
product = prev_product * vectorOld[i];
|
product = prev_product * vectorOld[i];
|
||||||
vectorNew[curr_dimension] += parameters[m] * product;
|
vectorNew[curr_dimension] += parameters[m] * product;
|
||||||
m++;
|
m++;
|
||||||
if (n < orde) {
|
if (n < orde) {
|
||||||
recur(curr_dimension, i, n+1, m, product);
|
recur(curr_dimension, i, n+1, m, product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
class Polynomial : public AttractorKernel {
|
class Polynomial : public AttractorKernel {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int orde;
|
unsigned int orde;
|
||||||
|
|
||||||
void recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product=1.0);
|
void recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product=1.0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Polynomial();
|
Polynomial();
|
||||||
Polynomial(const unsigned int dimensions, const unsigned int orde);
|
Polynomial(const unsigned int dimensions, const unsigned int orde);
|
||||||
|
|
||||||
virtual void operator()();
|
virtual void operator()();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//
|
//
|
||||||
// $filename
|
// $filename
|
||||||
// $projectname
|
// $projectname
|
||||||
//
|
//
|
||||||
// Created by Joshua moerman on $TODAY.
|
// Created by Joshua moerman on $TODAY.
|
||||||
// Copyright 2010 Joshua Moerman. All rights reserved.
|
// Copyright 2010 Joshua Moerman. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "PolynomialA3D.hpp"
|
#include "PolynomialA3D.hpp"
|
||||||
|
@ -23,14 +23,14 @@ PolynomialA3D::PolynomialA3D():
|
||||||
void PolynomialA3D::operator()() {
|
void PolynomialA3D::operator()() {
|
||||||
std::swap(vectorNew, vectorOld);
|
std::swap(vectorNew, vectorOld);
|
||||||
|
|
||||||
vectorNew[0] = parameters[0] + vectorOld[1] - vectorOld[1]*vectorOld[2];
|
vectorNew[0] = parameters[0] + vectorOld[1] - vectorOld[1]*vectorOld[2];
|
||||||
vectorNew[1] = parameters[1] + vectorOld[2] - vectorOld[2]*vectorOld[0];
|
vectorNew[1] = parameters[1] + vectorOld[2] - vectorOld[2]*vectorOld[0];
|
||||||
vectorNew[2] = parameters[2] + vectorOld[0] - vectorOld[0]*vectorOld[1];
|
vectorNew[2] = parameters[2] + vectorOld[0] - vectorOld[0]*vectorOld[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
N dimensional:
|
N dimensional:
|
||||||
for ( unsigned int i = 0; i < dim; i++ ) {
|
for ( unsigned int i = 0; i < dim; i++ ) {
|
||||||
new_point[i] = param[i] + point[(i+1) % dim] - point[(i+1) % dim]*point[(i+2) % dim];
|
new_point[i] = param[i] + point[(i+1) % dim] - point[(i+1) % dim]*point[(i+2) % dim];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,9 +8,9 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PolynomialA3D();
|
PolynomialA3D();
|
||||||
|
|
||||||
virtual void operator()();
|
virtual void operator()();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,18 +16,18 @@ Unravel3D::Unravel3D():
|
||||||
void Unravel3D::operator()() {
|
void Unravel3D::operator()() {
|
||||||
std::swap(vectorNew, vectorOld);
|
std::swap(vectorNew, vectorOld);
|
||||||
|
|
||||||
vectorNew[0] = parameters[0]*(vectorOld[2] + parameters[1]);
|
vectorNew[0] = parameters[0]*(vectorOld[2] + parameters[1]);
|
||||||
vectorNew[1] = parameters[2]*(vectorOld[0] + parameters[3]);
|
vectorNew[1] = parameters[2]*(vectorOld[0] + parameters[3]);
|
||||||
vectorNew[2] = parameters[4]*(vectorOld[1] + parameters[5]);
|
vectorNew[2] = parameters[4]*(vectorOld[1] + parameters[5]);
|
||||||
|
|
||||||
const double dist = vectorNew[0]*vectorNew[0] + vectorNew[1]*vectorNew[1] + vectorNew[2]*vectorNew[2];
|
const double dist = vectorNew[0]*vectorNew[0] + vectorNew[1]*vectorNew[1] + vectorNew[2]*vectorNew[2];
|
||||||
|
|
||||||
if ( dist > parameters[6]*parameters[6] ) {
|
if ( dist > parameters[6]*parameters[6] ) {
|
||||||
const double sqrtDist = std::sqrt(dist);
|
const double sqrtDist = std::sqrt(dist);
|
||||||
const double p = 1.0 - parameters[6] * ( static_cast<int> ( sqrtDist / parameters[6] ) + 1.0 ) / sqrtDist;
|
const double p = 1.0 - parameters[6] * ( static_cast<int> ( sqrtDist / parameters[6] ) + 1.0 ) / sqrtDist;
|
||||||
vectorNew[0] *= p;
|
vectorNew[0] *= p;
|
||||||
vectorNew[1] *= p;
|
vectorNew[1] *= p;
|
||||||
vectorNew[2] *= p;
|
vectorNew[2] *= p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
class Unravel3D : public AttractorKernel {
|
class Unravel3D : public AttractorKernel {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Unravel3D();
|
Unravel3D();
|
||||||
Unravel3D(const unsigned int dimensions);
|
Unravel3D(const unsigned int dimensions);
|
||||||
|
|
||||||
virtual void operator()();
|
virtual void operator()();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
64
main.cpp
64
main.cpp
|
@ -14,53 +14,53 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
clock_t start, end;
|
clock_t start, end;
|
||||||
double totalTime, totalIterations;
|
double totalTime, totalIterations;
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
// initialising stuff
|
// initialising stuff
|
||||||
Attractor myAttractor(ATTRACTOR_FILE);
|
Attractor myAttractor(ATTRACTOR_FILE);
|
||||||
|
|
||||||
Projector projection;
|
Projector projection;
|
||||||
Canvas canvas(WIDTH, HEIGHT, 3);
|
Canvas canvas(WIDTH, HEIGHT, 3);
|
||||||
projection.canvas = &canvas;
|
projection.canvas = &canvas;
|
||||||
|
|
||||||
myAttractor.projectors.push_back(&projection);
|
myAttractor.projectors.push_back(&projection);
|
||||||
myAttractor.init_range();
|
myAttractor.init_range();
|
||||||
|
|
||||||
projection.output();
|
projection.output();
|
||||||
|
|
||||||
unsigned int iterations = ITERATIONS;
|
unsigned int iterations = ITERATIONS;
|
||||||
start = clock();
|
start = clock();
|
||||||
for ( unsigned int j = 1; j <= 100; j++ ) {
|
for ( unsigned int j = 1; j <= 100; j++ ) {
|
||||||
for ( unsigned int i = 0; i <= iterations; i++ ) {
|
for ( unsigned int i = 0; i <= iterations; i++ ) {
|
||||||
myAttractor.iterate();
|
myAttractor.iterate();
|
||||||
myAttractor.plot();
|
myAttractor.plot();
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
myAttractor.output();
|
myAttractor.output();
|
||||||
std::cout << j << "% done" << std::endl;
|
std::cout << j << "% done" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
|
|
||||||
totalIterations = 100.0*iterations;
|
totalIterations = 100.0*iterations;
|
||||||
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
||||||
std::cout << std::endl << "total clock time: " << totalTime << std::endl;
|
std::cout << std::endl << "total clock time: " << totalTime << std::endl;
|
||||||
std::cout << "average iterations per second: " << totalIterations/((double)(end-start)/(double)(CLOCKS_PER_SEC)) << std::endl << std::endl;
|
std::cout << "average iterations per second: " << totalIterations/((double)(end-start)/(double)(CLOCKS_PER_SEC)) << std::endl << std::endl;
|
||||||
|
|
||||||
// saving output
|
// saving output
|
||||||
start = clock();
|
start = clock();
|
||||||
canvas.output_file();
|
canvas.output_file();
|
||||||
end = clock();
|
end = clock();
|
||||||
|
|
||||||
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
||||||
|
|
||||||
std::cout << "total clock time for writing png: " << totalTime << std::endl;
|
std::cout << "total clock time for writing png: " << totalTime << std::endl;
|
||||||
std::cout << std::endl << "Awesome Attractor, version " << __DATE__ << std::endl;
|
std::cout << std::endl << "Awesome Attractor, version " << __DATE__ << std::endl;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
bool even(double x) {
|
bool even(double x) {
|
||||||
return (((int)floor(x)) % 2 == 0);
|
return (((int)floor(x)) % 2 == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MYMATH_HPP
|
#endif // MYMATH_HPP
|
||||||
|
|
Reference in a new issue