diff --git a/particle.h b/particle.h index 31f5e7348c5ad2f680475b3d751a8252edbf0f58..3fa782b1303e03af472cafd07cef342df850694a 100644 --- a/particle.h +++ b/particle.h @@ -19,6 +19,7 @@ #include <iostream> #include <cstdlib> #include <cmath> +#include <vector> using namespace std; @@ -224,8 +225,24 @@ namespace PARTICLE{ } else return true; } - - + + // function added by Saad to choose a direction during deterministic streamlining + // the choosed direction is the one that is closest to current direction + unsigned int choose_dir(const vector<float>& th,const vector<float>& ph){ + float ps,tmpps=0; + unsigned int r=0; + + for(unsigned int i=0;i<th.size();i++){ + ps=tmpps; + tmpps=fabs((sin(th[i])*(cos(ph[i])*m_rx+sin(ph[i])*m_ry)+cos(ph[i])*m_rz)); + r = tmpps > ps ? i : r; + } + + return r; + + } + + friend ostream& operator<<(ostream& ostr,const Particle& p);