My old project for strange attractors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

146 lines
3.9 KiB

#include <iostream>
#include <ctime>
using namespace std;
#include "Attractor.hpp"
#include "Canvas.hpp"
#include "Projector.hpp"
int main(int argc, char *argv[]) {
clock_t start, end;
double totalTime, totalIterations;
// initialising stuff
15 years ago
Attractor myAttractor("attractors/testPolynomial.stf");
Projector projection;
Canvas canvas(8000, 8000, 3);
projection.canvas = &canvas;
myAttractor.projectors.push_back(&projection);
myAttractor.init_range();
projection.output();
// iterating 4 evah
unsigned int iterations = 800000000; // acht honderd miljoen
start = clock();
for ( unsigned int j = 1; j <= 100; j++ ) {
for ( unsigned int i = 0; i <= iterations; i++ ) {
myAttractor.iterate();
myAttractor.plot();
}
system("clear");
myAttractor.output();
cout << j << "% done" << endl;
}
end = clock();
totalIterations = 100.0*iterations;
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
printf("\ntotal clock time: %f\n", totalTime );
15 years ago
printf("average iterations per second: %f\n\n", totalIterations/((double)(end-start)/(double)(CLOCKS_PER_SEC)) );
// saving output
start = clock();
canvas.output_file();
end = clock();
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
15 years ago
printf("total clock time for writing png: %f\n", totalTime );
/*if ( argc <= 2 ) {
cout << endl << "nothing to do..." << endl;
cout << "usage:" << endl;
cout << " rendering to canvas: -a my_attractor.attr 500000000 my_attractor.canv 800 600 3" << endl;
cout << " canvas to png: -c my_attractor.canv 800 600 3 my_atttractor.png" << endl << endl;
exit(0);
}
int mode;
string argv1 = argv[1];
if ( argv1 == "-a" ) {
cout << "rendermode" << endl;
mode = 1;
} else if ( argv1 == "-c" ) {
cout << "canvasmode" << endl;
mode = 2;
} else {
cout << "i do.. i do... i do not understand... \"" << argv1 << "\""<< endl;
exit(0);
}
switch ( mode ) {
case 1: {
if ( argc != 8 ) {
cout << "all parameters must be set..." << endl;
exit(0);
}
string attractorFile = argv[2];
unsigned int iterations = atoi(argv[3]);
string canvasFile = argv[4];
unsigned int width = atoi(argv[5]);
unsigned int height = atoi(argv[6]);
unsigned int numColors = atoi(argv[7]);
Attractor attract(attractorFile.c_str());
cout << attractorFile << " is read" << endl;
Projector projection;
Canvas canvas(width, height, numColors);
projection.canvas = &canvas;
attract.projectors.push_back(&projection);
attract.init_range();
projection.output();
for ( unsigned int j = 1; j <= 100; j++ ) {
for ( unsigned int i = 0; 100*i <= iterations; i++ ) {
attract.iterate();
attract.plot();
}
cout << j << "% done" << endl;
}
canvas.output_raw(canvasFile.c_str());
cout << canvasFile << " is outputted" << endl;
break;
}
case 2: {
if ( argc != 7 ) {
cout << "all parameters must be set..." << endl;
exit(0);
}
string canvasFile = argv[2];
unsigned int width = atoi(argv[3]);
unsigned int height = atoi(argv[4]);
unsigned int numColors = atoi(argv[5]);
string pngFile = argv[6];
Canvas canvas(width, height, numColors);
canvas.input_raw(canvasFile.c_str());
cout << canvasFile << " is read" << endl;
for ( double v = -1.5; v < 1.6; v += 1.5 ) {
canvas.v = v;
canvas.output_file();
}
cout << pngFile << " was exported" << endl;
break;
}
default: {
cout << "WTF" << endl;
break;
}
}*/
return 0;
}