Victor
 All Data Structures Functions Variables Friends Pages
VectorTransformation.h
1 /* This file is part of Victor.
2 
3  Victor is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7 
8  Victor is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with Victor. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef _VECTORTRANSFORMATION_H_
18 #define _VECTORTRANSFORMATION_H_
19 
20 // Includes:
21 #include <Debug.h>
22 #include <vector>
23 #include <vector3.h>
24 #include <matrix3.h>
25 #include <IntCoordConverter.h>
26 
27 using namespace Victor::Biopool;
28 namespace Victor { namespace Lobo {
29 
30  // Global constants, typedefs, etc. (to avoid):
31 
38  public:
39 
40  // CONSTRUCTORS/DESTRUCTOR:
43  virtual ~VectorTransformation();
44 
45  // PREDICATES:
46  vgVector3<float> transform(vgVector3<float> orig);
47 
48  // MODIFIERS:
49  void addAlignVectors(vgVector3<float> v1, vgVector3<float> v2);
50  void addRot(vgMatrix3<float> rm);
51  void addTrans(vgVector3<float> t);
52  void clear();
53 
54  void copy(const VectorTransformation& orig);
55 
56  // OPERATORS:
57  VectorTransformation& operator=(const VectorTransformation& orig);
58 
59  protected:
60 
61  private:
62 
63  // HELPERS:
64  void addNewElem();
65 
66  // ATTRIBUTES:
67  vector<vgMatrix3<float> > rot;
68  vector<vgVector3<float> > trans;
69 
70  };
71 
72  // ---------------------------------------------------------------------------
73  // LoopModel
74  // -----------------x-------------------x-------------------x-----------------
75 
76  // MODIFIERS:
77 
83  inline void VectorTransformation::addAlignVectors(vgVector3<float> v1,
84  vgVector3<float> v2) {
85  vgMatrix3<float> tmpRefMat(1);
86  alignVectors(v1, v2, tmpRefMat);
87  addRot(tmpRefMat);
88  }
89 
90 
91  // HELPERS:
92 
98  inline void VectorTransformation::addNewElem() {
99  vgMatrix3<float> tmpM(1);
100  rot.push_back(tmpM);
101  vgVector3<float> tmpV(0, 0, 0);
102  trans.push_back(tmpV);
103  }
104 
110  inline vgVector3<double> convert(vgVector3<float> v) {
111  vgVector3<double> _v;
112  _v.x = v.x;
113  _v.y = v.y;
114  _v.z = v.z;
115  return _v;
116  }
117 
123  inline vgVector3<float> convert(vgVector3<double> v) {
124  vgVector3<float> _v;
125  _v.x = v.x;
126  _v.y = v.y;
127  _v.z = v.z;
128  return _v;
129  }
130 
136  inline vgMatrix3<float> convert(vgMatrix3<double> v) {
137  vgMatrix3<float> _v;
138  for (unsigned int i = 0; i < 9; i++)
139  _v[i] = v[i];
140  return _v;
141  }
142 
148  inline vgMatrix3<double> convert(vgMatrix3<float> v) {
149  vgMatrix3<double> _v;
150  for (unsigned int i = 0; i < 9; i++)
151  _v[i] = v[i];
152  return _v;
153  }
154 
155 }} // namespace
156 
157 #endif //_VECTORTRANSFORMATION_H_
158 
This class allows to store transformation steps for transforming a vector v into v' according to the ...
Definition: VectorTransformation.h:37