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.

77 lines
2.0 KiB

#include <iostream>
#include <ctime>
#include <valarray>
#include <cstring>
#include "Attractor.hpp"
#include "Canvas.hpp"
#include "Projector.hpp"
#include "defines.hpp"
int main(int argc, char *argv[]) {
std::cout << "Awesome Attractor, version " << __DATE__ << std::endl;
bool verbose = false;
std::string attractorFile = DEFAULT_ATTRACTOR_FILE;
unsigned int iterations = DEFAULT_ITERATIONS;
unsigned int width = DEFAULT_WIDTH;
unsigned int height = DEFAULT_HEIGHT;
for ( int i = 1; i < argc; ++i ) {
if ( strcmp(argv[i], "-v") == 0 ) {
verbose = true;
} else if ( strcmp(argv[i], "-w") == 0 ) {
width = atoi(argv[++i]);
} else if ( strcmp(argv[i], "-h") == 0 ) {
height = atoi(argv[++i]);
} else if ( strcmp(argv[i], "-i") == 0 ) {
iterations = atoi(argv[++i]);
} else {
attractorFile = argv[i];
}
}
// initialising stuff
Attractor myAttractor(attractorFile);
Projector projection;
Canvas canvas(width, height, 3);
projection.canvas = &canvas;
myAttractor.projectors.push_back(&projection);
myAttractor.init_range();
projection.output();
clock_t start, end;
start = clock();
for ( unsigned int j = 1; j <= 100; ++j ) {
for ( unsigned int i = 0; i <= iterations; i++ ) {
myAttractor.iterate();
myAttractor.plot();
}
std::cout << "\r" << j << "% done" << std::flush;
}
end = clock();
double totalIterations = 100.0*iterations;
double totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
std::cout << std::endl << "total clock time: " << totalTime << std::endl;
std::cout << "average iterations per second: " << totalIterations/totalTime << std::endl << std::endl;
// saving output
start = clock();
canvas.output_file();
end = clock();
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
std::cout << "total clock time for writing png: " << totalTime << std::endl;
return 0;
}