#include "Unravel3D.hpp" const static unsigned int dimension = 3; const static unsigned int numberOfParameters = 7; Unravel3D::Unravel3D(){ init(); } void Unravel3D::init() { // allocation myParameters = new double[numberOfParameters]; vectorNew = new double[dimension]; vectorOld = new double[dimension]; // initialisation assert(myParameters != NULL); assert(vectorNew != NULL); assert(vectorOld != NULL); for ( unsigned int i = 0; i < numberOfParameters; i++ ) { myParameters[i] = 0.0; } for ( unsigned int i = 0; i < dimension; i++ ) { vectorNew[i] = vectorOld[i] = 0.0; } } void Unravel3D::iterate() { swap(vectorNew, vectorOld); vectorNew[0] = myParameters[0]*(vectorOld[2] + myParameters[1]); vectorNew[1] = myParameters[2]*(vectorOld[0] + myParameters[3]); vectorNew[2] = myParameters[4]*(vectorOld[1] + myParameters[5]); const double dist = vectorNew[0]*vectorNew[0] + vectorNew[1]*vectorNew[1] + vectorNew[2]*vectorNew[2]; if ( dist > myParameters[6]*myParameters[6] ) { const double sqrtDist = sqrt(dist); const double p = 1.0 - myParameters[6] * ( static_cast ( sqrtDist / myParameters[6] ) + 1.0 ) / sqrtDist; vectorNew[0] *= p; vectorNew[1] *= p; vectorNew[2] *= p; } } // setters, getters, all i/o to other classes/objects void * Unravel3D::getProperty(const string identifier) { if ( identifier == "dimension" ) { unsigned int * _return = new unsigned int; *_return = dimension; return _return; } return NULL; } void Unravel3D::setProperty(const string identifier, const void * value) { return; } inline unsigned int Unravel3D::getNumberOfParameters() { return numberOfParameters; }