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.
 
 
 

69 lines
1.3 KiB

#ifndef PROJECTOR_HPP
#define PROJECTOR_HPP
#include "Logger.hpp"
#include <algorithm>
#include "stfu/stf.hpp"
#include "Canvas.hpp"
class Projector {
public:
Projector(unsigned int inputDimension, unsigned int outputDimension)
: projectedPoint(0)
, projectedColor(0)
, inputDimension(inputDimension)
, outputDimension(outputDimension)
, ready(true)
{
try {
allocate();
} catch(std::exception& e) {
LogError("Couldn't construct Projector: %s\n", e.what());
deallocate();
}
std::fill_n(projectedPoint, outputDimension, 0.0);
std::fill_n(projectedColor, 1, 0.0);
}
virtual ~Projector() {
deallocate();
}
void plot(const double* point) {
project(point);
}
static Projector* createProjector(stfu::node& projector, unsigned int input_dimension);
public:
double* projectedPoint;
double* projectedColor;
protected:
unsigned int inputDimension;
unsigned int outputDimension;
bool ready;
virtual void project(const double* point) = 0;
private:
void allocate() {
projectedPoint = new double[outputDimension];
projectedColor = new double[1];
}
void deallocate() {
delete[] projectedPoint;
projectedPoint = NULL;
delete[] projectedColor;
projectedColor = NULL;
}
Projector(Projector const &);
Projector & operator=(Projector const &);
};
#endif // PROJECTOR_HPP