OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Rotation.cpp
Go to the documentation of this file.
4 
5 #include <boost/regex.hpp>
6 
7 namespace mslang {
8  void Rotation::print(int indentwidth) {
9  std::string indent(indentwidth, ' ');
10  std::string indent2(indentwidth + 8, ' ');
11  std::cout << indent << "rotate, " << std::endl;
12  func_m->print(indentwidth + 8);
13  std::cout << ",\n"
14  << indent2 << "angle: " << angle_m;
15  }
16 
17  void Rotation::applyRotation(std::vector<std::shared_ptr<Base> > &bfuncs) {
18 
20  Vector_t(-sin(angle_m), cos(angle_m), 0.0));
21 
22  const unsigned int size = bfuncs.size();
23 
24  for (unsigned int j = 0; j < size; ++ j) {
25  std::shared_ptr<Base> &obj = bfuncs[j];
26  obj->trafo_m = obj->trafo_m.mult(rotation);
27 
28  if (obj->divisor_m.size() > 0)
29  applyRotation(obj->divisor_m);
30  }
31  }
32 
33  void Rotation::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
34  func_m->apply(bfuncs);
35  applyRotation(bfuncs);
36  }
37 
38  bool Rotation::parse_detail(iterator &it, const iterator &end, Function* &fun) {
39  Rotation *rot = static_cast<Rotation*>(fun);
40  if (!parse(it, end, rot->func_m)) return false;
41 
42  ArgumentExtractor arguments(std::string(++ it, end));
43  try {
44  rot->angle_m = parseMathExpression(arguments.get(0));
45  } catch (std::runtime_error &e) {
46  std::cout << e.what() << std::endl;
47  return false;
48  }
49 
50  it += (arguments.getLengthConsumed() + 1);
51 
52  return true;
53  }
54 }
unsigned int getLengthConsumed() const
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Rotation.cpp:33
constexpr double e
The value of .
Definition: Physics.h:40
void applyRotation(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Rotation.cpp:17
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
Function * func_m
Definition: Rotation.h:8
virtual void print(int indent)=0
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
virtual void apply(std::vector< std::shared_ptr< Base >> &bfuncs)=0
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition: MSLang.cpp:48
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition: Rotation.cpp:38
virtual void print(int indentwidth)
Definition: Rotation.cpp:8
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
std::string get(unsigned int i) const
double angle_m
Definition: Rotation.h:9
std::string::iterator iterator
Definition: MSLang.h:16
double parseMathExpression(const std::string &str)
Definition: matheval.cpp:4
Inform & endl(Inform &inf)
Definition: Inform.cpp:42