g4tools  5.4.0
rotd
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_rotd
5 #define tools_rotd
6 
7 // rotation done with quaternion.
8 
9 #include "qrot"
10 #include "vec3d"
11 #include "vec4d"
12 #include "mat3d"
13 #include "mat4d"
14 
15 namespace tools {
16 
17 class rotd : public qrot<vec3d,vec4d> {
18  typedef qrot<vec3d,vec4d> parent;
19 private:
20  rotd(double a_q0,double a_q1,double a_q2,double a_q3):parent(a_q0,a_q1,a_q2,a_q3){}
21 public:
22  rotd():parent() {} //zero rotation around the positive Z axis.
23  rotd(const vec3d& a_axis,double a_radians):parent(a_axis,a_radians,::sin,::cos) {}
24  rotd(const vec3d& a_from,const vec3d& a_to):parent(a_from,a_to,::sqrt,::fabs) {}
25  virtual ~rotd(){}
26 public:
27  rotd(const rotd& a_from):parent(a_from) {}
28  rotd& operator=(const rotd& a_from){
29  parent::operator=(a_from);
30  return *this;
31  }
32 public:
33  rotd& operator*=(const rotd& a_q) {
34  parent::operator*=(a_q);
35  return *this;
36  }
37  rotd operator*(const rotd& a_r) const {
38  rotd tmp(*this);
39  tmp *= a_r;
40  return tmp;
41  }
42 public:
43  bool set_value(const vec3d& a_from,const vec3d& a_to){
44  return parent::set_value(a_from,a_to,::sqrt,::fabs);
45  }
46  bool set_value(const vec3d& a_from,double a_a){
47  return parent::set_value(a_from,a_a,::sin,::cos);
48  }
49  bool value(vec3d& a_from,double& a_a) const {
50  return parent::value(a_from,a_a,::sin,::acos); //WARNING acos and not cos
51  }
52 
53  //NOTE : don't handle a static object because of mem balance.
54  //static const rotd& identity() {
55  // static const rotd s_v(0,0,0,1);
56  // return s_v;
57  //}
58 
59  void value(mat4d& a_m) const {parent::value(a_m);}
60  void set_value(const mat4d& a_m) {parent::set_value(a_m,::sqrt);}
61 
62  double value(mat3d& a_m) const {return parent::value_3(a_m);}
63 };
64 
65 }
66 
67 #endif
tools::rotd::rotd
rotd(const vec3d &a_from, const vec3d &a_to)
Definition: rotd:24
mat4d
tools::vec3d
Definition: vec3d:13
tools::rotd::set_value
void set_value(const mat4d &a_m)
Definition: rotd:60
tools::rotd::operator=
rotd & operator=(const rotd &a_from)
Definition: rotd:28
tools::mat4d
Definition: mat4d:12
tools::qrot< vec3d, vec4d >::value_3
T value_3(MAT3 &a_m) const
Definition: qrot:264
tools::rotd::value
double value(mat3d &a_m) const
Definition: rotd:62
vec4d
tools::rotd::value
void value(mat4d &a_m) const
Definition: rotd:59
tools::rotd::operator*
rotd operator*(const rotd &a_r) const
Definition: rotd:37
tools::rotd::rotd
rotd(const rotd &a_from)
Definition: rotd:27
tools::rotd::set_value
bool set_value(const vec3d &a_from, const vec3d &a_to)
Definition: rotd:43
tools::rotd::operator*=
rotd & operator*=(const rotd &a_q)
Definition: rotd:33
tools::qrot< vec3d, vec4d >::set_value
bool set_value(const vec3d &a_axis, T a_radians, T(*a_sin)(T), T(*a_cos)(T))
Definition: qrot:109
mat3d
tools::rotd::set_value
bool set_value(const vec3d &a_from, double a_a)
Definition: rotd:46
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::rotd
Definition: rotd:17
qrot
tools::rotd::~rotd
virtual ~rotd()
Definition: rotd:25
tools::qrot
Definition: qrot:12
tools::rotd::rotd
rotd(const vec3d &a_axis, double a_radians)
Definition: rotd:23
tools::qrot< vec3d, vec4d >::operator=
qrot & operator=(const qrot &a_from)
Definition: qrot:29
tools::qrot< vec3d, vec4d >::value
bool value(vec3d &a_axis, T &a_radians, T(*a_sin)(T), T(*a_acos)(T)) const
Definition: qrot:166
vec3d
tools::mat3d
Definition: mat3d:12
tools::rotd::value
bool value(vec3d &a_from, double &a_a) const
Definition: rotd:49
tools::qrot< vec3d, vec4d >::operator*=
qrot & operator*=(const qrot &a_q)
Definition: qrot:41
tools::rotd::rotd
rotd()
Definition: rotd:22