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.
100 lines
2.7 KiB
100 lines
2.7 KiB
/*
|
|
* AttractorKernel.cpp
|
|
* AwesomeAttractor
|
|
*
|
|
* Created by Joshua Moerman on 07-08-10.
|
|
* Copyright 2010 Rodo. All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "AttractorKernel.hpp"
|
|
#include "kernels/Logistic.hpp"
|
|
#include "kernels/Lorenz3D.hpp"
|
|
#include "kernels/Polynomial.hpp"
|
|
#include "kernels/PolynomialA3D.hpp"
|
|
#include "kernels/Unravel3D.hpp"
|
|
#include "kernels/UnravelHeart3D.hpp"
|
|
#include "kernels/Ikeda3D.hpp"
|
|
|
|
AttractorKernel* AttractorKernel::createAttractorKernel(stfu::node& attractor) {
|
|
|
|
AttractorKernel* myAttractor = NULL;
|
|
|
|
// reading basic stuff
|
|
const std::string attractorType = attractor.getValue("type");
|
|
const std::string attractorDimension = attractor.getValue("dimensions");
|
|
|
|
// for ( unsigned int i = 0; attractorType[i] != '\0'; i++ ) {
|
|
// attractorType[i] = tolower(attractorType[i]);
|
|
// }
|
|
const unsigned int dimension = atoi(attractorDimension.c_str());
|
|
|
|
LogMoreInfo(" Formula: %s\n", attractorType.c_str());
|
|
LogMoreInfo(" Dimensions: %d\n", dimension);
|
|
|
|
|
|
// depending on type, make the formula object
|
|
if(attractorType == "lorenz") {
|
|
if(dimension == 3) {
|
|
myAttractor = new Lorenz3D();
|
|
} else {
|
|
LogError("something wrong\n");
|
|
exit(37);
|
|
}
|
|
} else if(attractorType == "polynomial") {
|
|
const std::string attractorOrde = attractor.getValue("orde");
|
|
const unsigned int orde = atoi(attractorOrde.c_str());
|
|
LogMoreInfo(" Orde: %d\n", orde);
|
|
myAttractor = new Polynomial(dimension, orde);
|
|
|
|
} else if(attractorType == "polynomial a") {
|
|
if(dimension == 3) {
|
|
myAttractor = new PolynomialA3D();
|
|
} else {
|
|
LogError("something wrong\n");
|
|
exit(37);
|
|
}
|
|
} else if(attractorType == "logistic") {
|
|
myAttractor = new Logistic(dimension);
|
|
} else if(attractorType == "unravel") {
|
|
if(dimension == 3) {
|
|
myAttractor = new Unravel3D();
|
|
} else {
|
|
LogError("something wrong\n");
|
|
exit(37);
|
|
}
|
|
} else if(attractorType == "unravel heart") {
|
|
if(dimension == 3) {
|
|
myAttractor = new UnravelHeart3D();
|
|
} else {
|
|
LogError("something wrong\n");
|
|
exit(37);
|
|
}
|
|
} else if(attractorType == "ikeda") {
|
|
if(dimension == 3) {
|
|
myAttractor = new Ikeda3D();
|
|
} else {
|
|
LogError("something wrong\n");
|
|
exit(37);
|
|
}
|
|
} else {
|
|
LogError("'%s' not recognized\n", attractorType.c_str());
|
|
exit(37);
|
|
}
|
|
|
|
|
|
// read parameters
|
|
const unsigned int numberOfParameters = myAttractor->getNumberOfParameters();
|
|
|
|
if(attractor.children.find("parameters") != attractor.children.end())
|
|
for(unsigned int i = 0; i < numberOfParameters; i++) {
|
|
stfu::node attractorParameters = attractor.getChild("parameters");
|
|
(*myAttractor)[i] = atof(attractorParameters.getValue(i).c_str());
|
|
LogMoreInfo(" Parameter %d set to %f, ", i, (*myAttractor)[i]);
|
|
}
|
|
|
|
LogMoreInfo("\n Reading file complete\n");
|
|
|
|
return myAttractor;
|
|
}
|
|
|
|
|