1 |
< |
#ifndef __STUNTDOUBLE_HPP__ |
2 |
< |
#define __STUNTDOUBLE_HPP__ |
1 |
> |
/* |
2 |
> |
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
> |
* |
4 |
> |
* Contact: oopse@oopse.org |
5 |
> |
* |
6 |
> |
* This program is free software; you can redistribute it and/or |
7 |
> |
* modify it under the terms of the GNU Lesser General Public License |
8 |
> |
* as published by the Free Software Foundation; either version 2.1 |
9 |
> |
* of the License, or (at your option) any later version. |
10 |
> |
* All we ask is that proper credit is given for our work, which includes |
11 |
> |
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
> |
* of your source code files, and to any copyright notice that you may distribute |
13 |
> |
* with programs based on this work. |
14 |
> |
* |
15 |
> |
* This program is distributed in the hope that it will be useful, |
16 |
> |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
> |
* GNU Lesser General Public License for more details. |
19 |
> |
* |
20 |
> |
* You should have received a copy of the GNU Lesser General Public License |
21 |
> |
* along with this program; if not, write to the Free Software |
22 |
> |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
> |
* |
24 |
> |
*/ |
25 |
|
|
26 |
< |
#include <map> |
27 |
< |
#include "utils/GenericData.hpp" |
26 |
> |
/** |
27 |
> |
* @file StuntDouble.hpp |
28 |
> |
* @author tlin |
29 |
> |
* @date 10/22/2004 |
30 |
> |
* @version 1.0 |
31 |
> |
*/ |
32 |
> |
|
33 |
> |
#ifndef PRIMITIVES_STUNTDOUBLE_HPP |
34 |
> |
#define PRIMITIVES_STUNTDOUBLE_HPP |
35 |
|
|
36 |
< |
#define OT_ATOM 0 |
8 |
< |
#define OT_DATOM 1 |
9 |
< |
#define OT_RIGIDBODY 2 |
36 |
> |
#include <vector> |
37 |
|
|
38 |
< |
using namespace std; |
39 |
< |
using namespace oopse; |
38 |
> |
#include "visitors/BaseVisitor.hpp" |
39 |
> |
#include "math/Quaternion.hpp" |
40 |
> |
#include "math/SquareMatrix3.hpp" |
41 |
> |
#include "math/Vector3.hpp" |
42 |
> |
#include "utils/PropertyMap.hpp" |
43 |
> |
#include "brains/Snapshot.hpp" |
44 |
> |
#include "brains/SnapshotManager.hpp" |
45 |
> |
namespace oopse{ |
46 |
|
|
14 |
– |
class BaseVisitor; |
47 |
|
|
48 |
< |
class StuntDouble { |
49 |
< |
public: |
50 |
< |
virtual ~StuntDouble(); |
51 |
< |
|
52 |
< |
int getObjType(); |
53 |
< |
|
54 |
< |
bool isAtom(){ |
55 |
< |
return objType == OT_ATOM || objType == OT_DATOM; |
56 |
< |
} |
48 |
> |
|
49 |
> |
/** |
50 |
> |
* @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp" |
51 |
> |
* @brief |
52 |
> |
* StuntDouble is a very strange idea. A StuntDouble stands in for |
53 |
> |
* some object that can be manipulated by the Integrators or |
54 |
> |
* Minimizers. Some of the manipulable objects are Atoms, some are |
55 |
> |
* DirectionalAtoms, and some are RigidBodies. StuntDouble |
56 |
> |
* provides an interface for the Integrators and Minimizers to use, |
57 |
> |
* and does some preliminary sanity checking so that the program |
58 |
> |
* doesn't try to do something stupid like torque an Atom |
59 |
> |
* @note the dynamic data of stuntdouble will be stored outside of the class |
60 |
> |
*/ |
61 |
> |
class StuntDouble{ |
62 |
> |
public: |
63 |
|
|
64 |
< |
bool isDirectionalAtom(){ |
65 |
< |
return objType == OT_DATOM; |
66 |
< |
} |
64 |
> |
enum ObjectType{ |
65 |
> |
otAtom, |
66 |
> |
otDAtom, |
67 |
> |
otRigidBody |
68 |
> |
}; |
69 |
|
|
70 |
< |
bool isRigidBody(){ |
71 |
< |
return objType == OT_RIGIDBODY; |
72 |
< |
} |
70 |
> |
virtual ~StuntDouble(); |
71 |
> |
|
72 |
> |
/** |
73 |
> |
* Returns the global index of this stuntdouble. |
74 |
> |
* @return the global index of this stuntdouble |
75 |
> |
*/ |
76 |
> |
int getGlobalIndex() { |
77 |
> |
return globalIndex_; |
78 |
> |
} |
79 |
|
|
80 |
< |
bool isDirectional(){ |
81 |
< |
return isDirectionalAtom() || isRigidBody(); |
82 |
< |
} |
80 |
> |
/** |
81 |
> |
* Sets the global index of this stuntdouble. |
82 |
> |
* @param new global index to be set |
83 |
> |
*/ |
84 |
> |
int setGlobalIndex(int index) { |
85 |
> |
return globalIndex_; |
86 |
> |
} |
87 |
> |
|
88 |
> |
/** |
89 |
> |
* Returns the local index of this stuntdouble |
90 |
> |
* @return the local index of this stuntdouble |
91 |
> |
*/ |
92 |
> |
int getLocalIndex() { |
93 |
> |
return localIndex_; |
94 |
> |
} |
95 |
|
|
96 |
< |
virtual double getMass(void); |
97 |
< |
|
98 |
< |
virtual void getPos(double pos[3]); |
99 |
< |
virtual void setPos(double pos[3]); |
100 |
< |
|
101 |
< |
virtual void getVel(double vel[3]); |
102 |
< |
virtual void setVel(double vel[3]); |
45 |
< |
|
46 |
< |
virtual void getFrc(double frc[3]); |
47 |
< |
virtual void addFrc(double frc[3]); |
96 |
> |
/** |
97 |
> |
* Sets the local index of this stuntdouble |
98 |
> |
* @param index new index to be set |
99 |
> |
*/ |
100 |
> |
void setLocalIndex(int index) { |
101 |
> |
localIndex_ = index; |
102 |
> |
} |
103 |
|
|
104 |
< |
virtual void getA(double A[3][3]); |
105 |
< |
virtual void setA(double A[3][3]); |
104 |
> |
/** |
105 |
> |
* Sets the Snapshot Manager of this stuntdouble |
106 |
> |
*/ |
107 |
> |
void setSnapshotManager(SnapshotManager* sman) { |
108 |
> |
snapshotMan_ = sman; |
109 |
> |
} |
110 |
|
|
111 |
< |
virtual void getJ(double j[3]); |
112 |
< |
virtual void setJ(double j[3]); |
111 |
> |
/** |
112 |
> |
* Tests if this stuntdouble is an atom |
113 |
> |
* @return true is this stuntdouble is an atom(or a directional atom), return false otherwise |
114 |
> |
*/ |
115 |
> |
bool isAtom(){ |
116 |
> |
return objType_ == otAtom || objType_ == otDAtom; |
117 |
> |
} |
118 |
|
|
119 |
< |
virtual void getQ( double q[4] ); // get the quanternions |
120 |
< |
virtual void setQ( double q[4] ); |
119 |
> |
/** |
120 |
> |
* Tests if this stuntdouble is an directional atom |
121 |
> |
* @return true if this stuntdouble is an directional atom, return false otherwise |
122 |
> |
*/ |
123 |
> |
bool isDirectionalAtom(){ |
124 |
> |
return objType_ == otDAtom; |
125 |
> |
} |
126 |
|
|
127 |
< |
virtual void setType(char* type) = 0; |
128 |
< |
virtual char* getType() = 0; |
129 |
< |
|
127 |
> |
/** |
128 |
> |
* Tests if this stuntdouble is a rigid body. |
129 |
> |
* @return true if this stuntdouble is a rigid body, otherwise return false |
130 |
> |
*/ |
131 |
> |
bool isRigidBody(){ |
132 |
> |
return objType_ == otRigidBody; |
133 |
> |
} |
134 |
|
|
135 |
< |
virtual void getTrq(double trq[3]); |
136 |
< |
virtual void addTrq(double trq[3]); |
135 |
> |
/** |
136 |
> |
* Tests if this stuntdouble is a directional one. |
137 |
> |
* @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise |
138 |
> |
*/ |
139 |
> |
bool isDirectional(){ |
140 |
> |
return isDirectionalAtom() || isRigidBody(); |
141 |
> |
} |
142 |
|
|
143 |
< |
virtual void getI(double I[3][3]); |
144 |
< |
virtual void lab2Body(double vec[3]); |
143 |
> |
/** |
144 |
> |
* Returns the previous position of this stuntdouble |
145 |
> |
* @return the position of this stuntdouble |
146 |
> |
*/ |
147 |
> |
Vector3d getPrevPos() { |
148 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_]; |
149 |
> |
} |
150 |
> |
|
151 |
> |
/** |
152 |
> |
* Returns the current position of this stuntdouble |
153 |
> |
* @return the position of this stuntdouble |
154 |
> |
*/ |
155 |
> |
Vector3d getPos() { |
156 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_]; |
157 |
> |
} |
158 |
|
|
159 |
< |
virtual void getGrad(double grad[6]); |
160 |
< |
virtual void setEuler(double phi, double theta, double psi); |
161 |
< |
virtual void getEulerAngles(double eulers[3]); |
159 |
> |
/** |
160 |
> |
* Returns the position of this stuntdouble in specified snapshot |
161 |
> |
* @return the position of this stuntdouble |
162 |
> |
* @param snapshotNo |
163 |
> |
*/ |
164 |
> |
Vector3d getPos(int snapshotNo) { |
165 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_]; |
166 |
> |
} |
167 |
|
|
168 |
< |
virtual bool isLinear() {return false;} |
169 |
< |
virtual int linearAxis() {return -1;} |
168 |
> |
/** |
169 |
> |
* Sets the previous position of this stuntdouble |
170 |
> |
* @param pos new position |
171 |
> |
* @see #getPos |
172 |
> |
*/ |
173 |
> |
void setPrevPos(const Vector3d& pos) { |
174 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_] = pos; |
175 |
> |
} |
176 |
> |
|
177 |
> |
/** |
178 |
> |
* Sets the current position of this stuntdouble |
179 |
> |
* @param pos new position |
180 |
> |
*/ |
181 |
> |
void setPos(const Vector3d& pos) { |
182 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_] = pos; |
183 |
> |
} |
184 |
|
|
185 |
< |
virtual double getZangle(); |
186 |
< |
virtual void setZangle(double zAngle); |
187 |
< |
virtual void addZangle(double zAngle); |
188 |
< |
|
189 |
< |
virtual void accept(BaseVisitor* v) = 0; |
190 |
< |
|
191 |
< |
void addProperty(GenericData* data); |
192 |
< |
void removeProperty(const string& propName); |
193 |
< |
GenericData* getProperty(const string& propName); |
194 |
< |
|
195 |
< |
protected: |
196 |
< |
StuntDouble(){} |
185 |
> |
/** |
186 |
> |
* Sets the position of this stuntdouble in specified snapshot |
187 |
> |
* @param pos position to be set |
188 |
> |
* @param snapshotNo |
189 |
> |
* @see #getPos |
190 |
> |
*/ |
191 |
> |
void setPos(const Vector3d& pos, int snapshotNo) { |
192 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos; |
193 |
> |
} |
194 |
> |
|
195 |
> |
/** |
196 |
> |
* Returns the previous velocity of this stuntdouble |
197 |
> |
* @return the velocity of this stuntdouble |
198 |
> |
*/ |
199 |
> |
Vector3d getPrevVel() { |
200 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_]; |
201 |
> |
} |
202 |
> |
|
203 |
> |
/** |
204 |
> |
* Returns the current velocity of this stuntdouble |
205 |
> |
* @return the velocity of this stuntdouble |
206 |
> |
*/ |
207 |
> |
Vector3d getVel() { |
208 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_]; |
209 |
> |
} |
210 |
|
|
211 |
< |
//prevent default copy constructor copy information from properties which will cause problem |
212 |
< |
StuntDouble(const StuntDouble& sd){ |
213 |
< |
objType = sd.objType; |
214 |
< |
} |
215 |
< |
|
216 |
< |
int objType; |
211 |
> |
/** |
212 |
> |
* Returns the velocity of this stuntdouble in specified snapshot |
213 |
> |
* @return the velocity of this stuntdouble |
214 |
> |
* @param snapshotNo |
215 |
> |
*/ |
216 |
> |
Vector3d getVel(int snapshotNo) { |
217 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_]; |
218 |
> |
} |
219 |
|
|
220 |
< |
map<string, GenericData*> properties; |
221 |
< |
}; |
220 |
> |
/** |
221 |
> |
* Sets the previous velocity of this stuntdouble |
222 |
> |
* @param vel new velocity |
223 |
> |
* @see #getVel |
224 |
> |
*/ |
225 |
> |
void setPrevVel(const Vector3d& vel) { |
226 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_] = vel; |
227 |
> |
} |
228 |
> |
|
229 |
> |
/** |
230 |
> |
* Sets the current velocity of this stuntdouble |
231 |
> |
* @param vel new velocity |
232 |
> |
*/ |
233 |
> |
void setVel(const Vector3d& vel) { |
234 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_] = vel; |
235 |
> |
} |
236 |
|
|
237 |
< |
#endif |
237 |
> |
/** |
238 |
> |
* Sets the velocity of this stuntdouble in specified snapshot |
239 |
> |
* @param vel velocity to be set |
240 |
> |
* @param snapshotNo |
241 |
> |
* @see #getVel |
242 |
> |
*/ |
243 |
> |
void setVel(const Vector3d& vel, int snapshotNo) { |
244 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_] = vel; |
245 |
> |
} |
246 |
> |
|
247 |
> |
/** |
248 |
> |
* Returns the previous rotation matrix of this stuntdouble |
249 |
> |
* @return the rotation matrix of this stuntdouble |
250 |
> |
*/ |
251 |
> |
RotMat3x3d getPrevA() { |
252 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_]; |
253 |
> |
} |
254 |
> |
|
255 |
> |
/** |
256 |
> |
* Returns the current rotation matrix of this stuntdouble |
257 |
> |
* @return the rotation matrix of this stuntdouble |
258 |
> |
*/ |
259 |
> |
RotMat3x3d getA() { |
260 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_]; |
261 |
> |
} |
262 |
> |
|
263 |
> |
/** |
264 |
> |
* Returns the rotation matrix of this stuntdouble in specified snapshot |
265 |
> |
* |
266 |
> |
* @return the rotation matrix of this stuntdouble |
267 |
> |
* @param snapshotNo |
268 |
> |
*/ |
269 |
> |
RotMat3x3d getA(int snapshotNo) { |
270 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_]; |
271 |
> |
} |
272 |
> |
|
273 |
> |
/** |
274 |
> |
* Sets the previous rotation matrix of this stuntdouble |
275 |
> |
* @param a new rotation matrix |
276 |
> |
* @see #getA |
277 |
> |
*/ |
278 |
> |
virtual void setPrevA(const RotMat3x3d& a) { |
279 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a; |
280 |
> |
} |
281 |
> |
|
282 |
> |
/** |
283 |
> |
* Sets the current rotation matrix of this stuntdouble |
284 |
> |
* @param a new rotation matrix |
285 |
> |
*/ |
286 |
> |
virtual void setA(const RotMat3x3d& a) { |
287 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a; |
288 |
> |
} |
289 |
> |
|
290 |
> |
/** |
291 |
> |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
292 |
> |
* @param a rotation matrix to be set |
293 |
> |
* @param snapshotNo |
294 |
> |
* @see #getA |
295 |
> |
*/ |
296 |
> |
virtual void setA(const RotMat3x3d& a, int snapshotNo) { |
297 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a; |
298 |
> |
} |
299 |
> |
|
300 |
> |
/** |
301 |
> |
* Returns the previous angular momentum of this stuntdouble (body-fixed). |
302 |
> |
* @return the angular momentum of this stuntdouble |
303 |
> |
*/ |
304 |
> |
Vector3d getPrevJ() { |
305 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_]; |
306 |
> |
} |
307 |
> |
|
308 |
> |
/** |
309 |
> |
* Returns the current angular momentum of this stuntdouble (body -fixed). |
310 |
> |
* @return the angular momentum of this stuntdouble |
311 |
> |
*/ |
312 |
> |
Vector3d getJ() { |
313 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_]; |
314 |
> |
} |
315 |
> |
|
316 |
> |
/** |
317 |
> |
* Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed). |
318 |
> |
* @return the angular momentum of this stuntdouble |
319 |
> |
* @param snapshotNo |
320 |
> |
*/ |
321 |
> |
Vector3d getJ(int snapshotNo) { |
322 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_]; |
323 |
> |
} |
324 |
> |
|
325 |
> |
/** |
326 |
> |
* Sets the previous angular momentum of this stuntdouble (body-fixed). |
327 |
> |
* @param angMom new angular momentum |
328 |
> |
* @see #getJ |
329 |
> |
*/ |
330 |
> |
void setPrevJ(const Vector3d& angMom) { |
331 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_] = angMom; |
332 |
> |
} |
333 |
> |
|
334 |
> |
/** |
335 |
> |
* Sets the current angular momentum of this stuntdouble (body-fixed). |
336 |
> |
* @param angMom new angular momentum |
337 |
> |
*/ |
338 |
> |
void setJ(const Vector3d& angMom) { |
339 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_] = angMom; |
340 |
> |
} |
341 |
> |
|
342 |
> |
/** |
343 |
> |
* Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed). |
344 |
> |
* @param angMom angular momentum to be set |
345 |
> |
* @param snapshotNo |
346 |
> |
* @see #getJ |
347 |
> |
*/ |
348 |
> |
void setJ(const Vector3d& angMom, int snapshotNo) { |
349 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom; |
350 |
> |
} |
351 |
> |
|
352 |
> |
/** |
353 |
> |
* Returns the previous quaternion of this stuntdouble |
354 |
> |
* @return the quaternion of this stuntdouble |
355 |
> |
*/ |
356 |
> |
Quat4d getPrevQ() { |
357 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toQuaternion(); |
358 |
> |
} |
359 |
> |
|
360 |
> |
/** |
361 |
> |
* Returns the current quaternion of this stuntdouble |
362 |
> |
* @return the quaternion of this stuntdouble |
363 |
> |
*/ |
364 |
> |
Quat4d getQ() { |
365 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toQuaternion(); |
366 |
> |
} |
367 |
> |
|
368 |
> |
/** |
369 |
> |
* Returns the quaternion of this stuntdouble in specified snapshot |
370 |
> |
* @return the quaternion of this stuntdouble |
371 |
> |
* @param snapshotNo |
372 |
> |
*/ |
373 |
> |
Quat4d getQ(int snapshotNo) { |
374 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toQuaternion(); |
375 |
> |
} |
376 |
> |
|
377 |
> |
/** |
378 |
> |
* Sets the previous quaternion of this stuntdouble |
379 |
> |
* @param q new quaternion |
380 |
> |
* @note actual storage data is rotation matrix |
381 |
> |
*/ |
382 |
> |
void setPrevQ(const Quat4d& q) { |
383 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = q; |
384 |
> |
} |
385 |
> |
|
386 |
> |
/** |
387 |
> |
* Sets the current quaternion of this stuntdouble |
388 |
> |
* @param q new quaternion |
389 |
> |
* @note actual storage data is rotation matrix |
390 |
> |
*/ |
391 |
> |
void setQ(const Quat4d& q) { |
392 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = q; |
393 |
> |
} |
394 |
> |
|
395 |
> |
/** |
396 |
> |
* Sets the quaternion of this stuntdouble in specified snapshot |
397 |
> |
* |
398 |
> |
* @param q quaternion to be set |
399 |
> |
* @param snapshotNo |
400 |
> |
* @note actual storage data is rotation matrix |
401 |
> |
*/ |
402 |
> |
void setQ(const Quat4d& q, int snapshotNo) { |
403 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = q; |
404 |
> |
} |
405 |
> |
|
406 |
> |
/** |
407 |
> |
* Returns the previous euler angles of this stuntdouble |
408 |
> |
* @return the euler angles of this stuntdouble |
409 |
> |
*/ |
410 |
> |
Vector3d getPrevEuler() { |
411 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toEulerAngles(); |
412 |
> |
} |
413 |
> |
|
414 |
> |
/** |
415 |
> |
* Returns the current euler angles of this stuntdouble |
416 |
> |
* @return the euler angles of this stuntdouble |
417 |
> |
*/ |
418 |
> |
Vector3d getEuler() { |
419 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toEulerAngles(); |
420 |
> |
} |
421 |
> |
|
422 |
> |
/** |
423 |
> |
* Returns the euler angles of this stuntdouble in specified snapshot. |
424 |
> |
* @return the euler angles of this stuntdouble |
425 |
> |
* @param snapshotNo |
426 |
> |
*/ |
427 |
> |
Vector3d getEuler(int snapshotNo) { |
428 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toEulerAngles(); |
429 |
> |
} |
430 |
> |
|
431 |
> |
/** |
432 |
> |
* Sets the previous euler angles of this stuntdouble. |
433 |
> |
* @param euler new euler angles |
434 |
> |
* @see #getEuler |
435 |
> |
* @note actual storage data is rotation matrix |
436 |
> |
*/ |
437 |
> |
void setPrevEuler(const Vector3d& euler) { |
438 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = euler; |
439 |
> |
} |
440 |
> |
|
441 |
> |
/** |
442 |
> |
* Sets the current euler angles of this stuntdouble |
443 |
> |
* @param euler new euler angles |
444 |
> |
*/ |
445 |
> |
void setEuler(const Vector3d& euler) { |
446 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = euler; |
447 |
> |
} |
448 |
> |
|
449 |
> |
/** |
450 |
> |
* Sets the euler angles of this stuntdouble in specified snapshot |
451 |
> |
* |
452 |
> |
* @param euler euler angles to be set |
453 |
> |
* @param snapshotNo |
454 |
> |
* @note actual storage data is rotation matrix |
455 |
> |
*/ |
456 |
> |
void setEuler(const Vector3d& euler, int snapshotNo) { |
457 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = euler; |
458 |
> |
} |
459 |
> |
|
460 |
> |
/** |
461 |
> |
* Returns the previous unit vectors of this stuntdouble |
462 |
> |
* @return the unit vectors of this stuntdouble |
463 |
> |
*/ |
464 |
> |
RotMat3x3d getPrevElectroFrame() { |
465 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_]; |
466 |
> |
} |
467 |
> |
|
468 |
> |
/** |
469 |
> |
* Returns the current unit vectors of this stuntdouble |
470 |
> |
* @return the unit vectors of this stuntdouble |
471 |
> |
*/ |
472 |
> |
RotMat3x3d getElectroFrame() { |
473 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_]; |
474 |
> |
} |
475 |
> |
|
476 |
> |
/** |
477 |
> |
* Returns the unit vectors of this stuntdouble in specified snapshot |
478 |
> |
* |
479 |
> |
* @return the unit vectors of this stuntdouble |
480 |
> |
* @param snapshotNo |
481 |
> |
*/ |
482 |
> |
RotMat3x3d getElectroFrame(int snapshotNo) { |
483 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_]; |
484 |
> |
} |
485 |
> |
|
486 |
> |
/** |
487 |
> |
* Returns the previous force of this stuntdouble |
488 |
> |
* @return the force of this stuntdouble |
489 |
> |
*/ |
490 |
> |
Vector3d getPrevFrc() { |
491 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_]; |
492 |
> |
} |
493 |
> |
|
494 |
> |
/** |
495 |
> |
* Returns the current force of this stuntdouble |
496 |
> |
* @return the force of this stuntdouble |
497 |
> |
*/ |
498 |
> |
Vector3d getFrc() { |
499 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_]; |
500 |
> |
} |
501 |
> |
|
502 |
> |
/** |
503 |
> |
* Returns the force of this stuntdouble in specified snapshot |
504 |
> |
* |
505 |
> |
* @return the force of this stuntdouble |
506 |
> |
* @param snapshotNo |
507 |
> |
*/ |
508 |
> |
Vector3d getFrc(int snapshotNo) { |
509 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_]; |
510 |
> |
} |
511 |
> |
|
512 |
> |
/** |
513 |
> |
* Sets the previous force of this stuntdouble |
514 |
> |
* |
515 |
> |
* @param frc new force |
516 |
> |
* @see #getFrc |
517 |
> |
*/ |
518 |
> |
void setPrevFrc(const Vector3d& frc) { |
519 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] = frc; |
520 |
> |
} |
521 |
> |
|
522 |
> |
/** |
523 |
> |
* Sets the current force of this stuntdouble |
524 |
> |
* @param frc new force |
525 |
> |
*/ |
526 |
> |
void setFrc(const Vector3d& frc) { |
527 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] = frc; |
528 |
> |
} |
529 |
> |
|
530 |
> |
/** |
531 |
> |
* Sets the force of this stuntdouble in specified snapshot |
532 |
> |
* |
533 |
> |
* @param frc force to be set |
534 |
> |
* @param snapshotNo |
535 |
> |
* @see #getFrc |
536 |
> |
*/ |
537 |
> |
void setFrc(const Vector3d& frc, int snapshotNo) { |
538 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] = frc; |
539 |
> |
} |
540 |
> |
|
541 |
> |
/** |
542 |
> |
* Adds force into the previous force of this stuntdouble |
543 |
> |
* |
544 |
> |
* @param frc new force |
545 |
> |
* @see #getFrc |
546 |
> |
*/ |
547 |
> |
void addPrevFrc(const Vector3d& frc) { |
548 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] += frc; |
549 |
> |
} |
550 |
> |
|
551 |
> |
/** |
552 |
> |
* Adds force into the current force of this stuntdouble |
553 |
> |
* @param frc new force |
554 |
> |
*/ |
555 |
> |
void addFrc(const Vector3d& frc) { |
556 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] += frc; |
557 |
> |
} |
558 |
> |
|
559 |
> |
/** |
560 |
> |
* Adds force into the force of this stuntdouble in specified snapshot |
561 |
> |
* |
562 |
> |
* @param frc force to be set |
563 |
> |
* @param snapshotNo |
564 |
> |
* @see #getFrc |
565 |
> |
*/ |
566 |
> |
void addFrc(const Vector3d& frc, int snapshotNo) { |
567 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] += frc; |
568 |
> |
} |
569 |
> |
|
570 |
> |
/** |
571 |
> |
* Returns the previous torque of this stuntdouble |
572 |
> |
* @return the torque of this stuntdouble |
573 |
> |
*/ |
574 |
> |
Vector3d getPrevTrq() { |
575 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_]; |
576 |
> |
} |
577 |
> |
|
578 |
> |
/** |
579 |
> |
* Returns the current torque of this stuntdouble |
580 |
> |
* @return the torque of this stuntdouble |
581 |
> |
*/ |
582 |
> |
Vector3d getTrq() { |
583 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_]; |
584 |
> |
} |
585 |
> |
|
586 |
> |
/** |
587 |
> |
* Returns the torque of this stuntdouble in specified snapshot |
588 |
> |
* |
589 |
> |
* @return the torque of this stuntdouble |
590 |
> |
* @param snapshotNo |
591 |
> |
*/ |
592 |
> |
Vector3d getTrq(int snapshotNo) { |
593 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_]; |
594 |
> |
} |
595 |
> |
|
596 |
> |
/** |
597 |
> |
* Sets the previous torque of this stuntdouble |
598 |
> |
* |
599 |
> |
* @param trq new torque |
600 |
> |
* @see #getTrq |
601 |
> |
*/ |
602 |
> |
void setPrevTrq(const Vector3d& trq) { |
603 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] = trq; |
604 |
> |
} |
605 |
> |
|
606 |
> |
/** |
607 |
> |
* Sets the current torque of this stuntdouble |
608 |
> |
* @param trq new torque |
609 |
> |
*/ |
610 |
> |
void setTrq(const Vector3d& trq) { |
611 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] = trq; |
612 |
> |
} |
613 |
> |
|
614 |
> |
/** |
615 |
> |
* Sets the torque of this stuntdouble in specified snapshot |
616 |
> |
* |
617 |
> |
* @param trq torque to be set |
618 |
> |
* @param snapshotNo |
619 |
> |
* @see #getTrq |
620 |
> |
*/ |
621 |
> |
void setTrq(const Vector3d& trq, int snapshotNo) { |
622 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] = trq; |
623 |
> |
} |
624 |
> |
|
625 |
> |
/** |
626 |
> |
* Adds torque into the previous torque of this stuntdouble |
627 |
> |
* |
628 |
> |
* @param trq new torque |
629 |
> |
* @see #getTrq |
630 |
> |
*/ |
631 |
> |
void addPrevTrq(const Vector3d& trq) { |
632 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] += trq; |
633 |
> |
} |
634 |
> |
|
635 |
> |
/** |
636 |
> |
* Adds torque into the current torque of this stuntdouble |
637 |
> |
* @param trq new torque |
638 |
> |
*/ |
639 |
> |
void addTrq(const Vector3d& trq) { |
640 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] += trq; |
641 |
> |
} |
642 |
> |
|
643 |
> |
/** |
644 |
> |
* Adds torque into the torque of this stuntdouble in specified snapshot |
645 |
> |
* |
646 |
> |
* @param trq torque to be add |
647 |
> |
* @param snapshotNo |
648 |
> |
* @see #getTrq |
649 |
> |
*/ |
650 |
> |
void addTrq(const Vector3d& trq, int snapshotNo) { |
651 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] += trq; |
652 |
> |
} |
653 |
> |
|
654 |
> |
|
655 |
> |
/** |
656 |
> |
* Returns the previous z-angle of this stuntdouble |
657 |
> |
* @return the z-angle of this stuntdouble |
658 |
> |
*/ |
659 |
> |
double getPrevZangle() { |
660 |
> |
return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_]; |
661 |
> |
} |
662 |
> |
|
663 |
> |
/** |
664 |
> |
* Returns the current z-angle of this stuntdouble |
665 |
> |
* @return the z-angle of this stuntdouble |
666 |
> |
*/ |
667 |
> |
double getZangle() { |
668 |
> |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_]; |
669 |
> |
} |
670 |
> |
|
671 |
> |
/** |
672 |
> |
* Returns the z-angle of this stuntdouble in specified snapshot |
673 |
> |
* @return the z-angle of this stuntdouble |
674 |
> |
* @param snapshotNo |
675 |
> |
*/ |
676 |
> |
double getZangle(int snapshotNo) { |
677 |
> |
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_]; |
678 |
> |
} |
679 |
> |
|
680 |
> |
/** |
681 |
> |
* Sets the previous z-angle of this stuntdouble |
682 |
> |
* @param angle new z-angle |
683 |
> |
* @see #getZangle |
684 |
> |
*/ |
685 |
> |
void setPrevZangle(double angle) { |
686 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle; |
687 |
> |
} |
688 |
> |
|
689 |
> |
/** |
690 |
> |
* Sets the current z-angle of this stuntdouble |
691 |
> |
* @param angle new z-angle |
692 |
> |
*/ |
693 |
> |
void setZangle(double angle) { |
694 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle; |
695 |
> |
} |
696 |
> |
|
697 |
> |
/** |
698 |
> |
* Sets the z-angle of this stuntdouble in specified snapshot |
699 |
> |
* @param angle z-angle to be set |
700 |
> |
* @param snapshotNo |
701 |
> |
* @see #getZangle |
702 |
> |
*/ |
703 |
> |
void setZangle(double angle, int snapshotNo) { |
704 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle; |
705 |
> |
} |
706 |
> |
|
707 |
> |
/** |
708 |
> |
* Adds z-angle into the previous z-angle of this stuntdouble |
709 |
> |
* @param angle new z-angle |
710 |
> |
* @see #getZangle |
711 |
> |
*/ |
712 |
> |
void addPrevZangle(double angle) { |
713 |
> |
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle; |
714 |
> |
} |
715 |
> |
|
716 |
> |
/** |
717 |
> |
* Adds z-angle into the current z-angle of this stuntdouble |
718 |
> |
* @param angle new z-angle |
719 |
> |
*/ |
720 |
> |
void addZangle(double angle) { |
721 |
> |
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle; |
722 |
> |
} |
723 |
> |
|
724 |
> |
/** |
725 |
> |
* Adds z-angle into the z-angle of this stuntdouble in specified snapshot |
726 |
> |
* @param angle z-angle to be add |
727 |
> |
* @param snapshotNo |
728 |
> |
* @see #getZangle |
729 |
> |
*/ |
730 |
> |
void addZangle(double angle, int snapshotNo) { |
731 |
> |
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle; |
732 |
> |
} |
733 |
> |
|
734 |
> |
/** Set the force of this stuntdouble to zero */ |
735 |
> |
virtual void zeroForces(); |
736 |
> |
/** |
737 |
> |
* Returns the inertia tensor of this stuntdouble |
738 |
> |
* @return the inertia tensor of this stuntdouble |
739 |
> |
*/ |
740 |
> |
virtual Mat3x3d getI() = 0; |
741 |
> |
|
742 |
> |
/** |
743 |
> |
* Returns the gradient of this stuntdouble |
744 |
> |
* @return the gradient of this stuntdouble |
745 |
> |
*/ |
746 |
> |
virtual std::vector<double> getGrad() = 0; |
747 |
> |
|
748 |
> |
/** |
749 |
> |
* Tests the if this stuntdouble is a linear rigidbody |
750 |
> |
* |
751 |
> |
* @return true if this stuntdouble is a linear rigidbody, otherwise return false |
752 |
> |
* @note atom and directional atom will always return false |
753 |
> |
* |
754 |
> |
* @see #linearAxis |
755 |
> |
*/ |
756 |
> |
bool isLinear() { |
757 |
> |
return linear_; |
758 |
> |
} |
759 |
> |
|
760 |
> |
/** |
761 |
> |
* Returns the linear axis of the rigidbody, atom and directional atom will always return -1 |
762 |
> |
* |
763 |
> |
* @return the linear axis of the rigidbody |
764 |
> |
* |
765 |
> |
* @see #isLinear |
766 |
> |
*/ |
767 |
> |
int linearAxis() { |
768 |
> |
return linearAxis_; |
769 |
> |
} |
770 |
> |
|
771 |
> |
/** Returns the mass of this stuntdouble */ |
772 |
> |
double getMass() { |
773 |
> |
return mass_; |
774 |
> |
} |
775 |
> |
|
776 |
> |
/** |
777 |
> |
* Sets the mass of this stuntdoulbe |
778 |
> |
* @param mass the mass to be set |
779 |
> |
*/ |
780 |
> |
void setMass(double mass) { |
781 |
> |
mass_ = mass; |
782 |
> |
} |
783 |
> |
|
784 |
> |
/** Returns the name of this stuntdouble */ |
785 |
> |
std::string getType(); |
786 |
> |
|
787 |
> |
/** Sets the name of this stuntdouble*/ |
788 |
> |
void setType(const std::string& name); |
789 |
> |
|
790 |
> |
/** |
791 |
> |
* Converts a lab fixed vector to a body fixed vector. |
792 |
> |
* @return body fixed vector |
793 |
> |
* @param v lab fixed vector |
794 |
> |
*/ |
795 |
> |
Vector3d lab2Body(const Vector3d& v); |
796 |
> |
|
797 |
> |
/** |
798 |
> |
* Converts a body fixed vector to a lab fixed vector. |
799 |
> |
* @return corresponding lab fixed vector |
800 |
> |
* @param v body fixed vector |
801 |
> |
*/ |
802 |
> |
Vector3d body2Lab(const Vector3d& v); |
803 |
> |
/** |
804 |
> |
* <p> |
805 |
> |
* The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on |
806 |
> |
* the elements of a data structure. In this way, you can change the operation being performed |
807 |
> |
* on a structure without the need of changing the classes of the elements that you are operating |
808 |
> |
* on. Using a Visitor pattern allows you to decouple the classes for the data structure and the |
809 |
> |
* algorithms used upon them |
810 |
> |
* </p> |
811 |
> |
* @param v visitor |
812 |
> |
*/ |
813 |
> |
virtual void accept(BaseVisitor* v) = 0; |
814 |
> |
|
815 |
> |
//below functions are just forward functions |
816 |
> |
/** |
817 |
> |
* Adds property into property map |
818 |
> |
* @param genData GenericData to be added into PropertyMap |
819 |
> |
*/ |
820 |
> |
void addProperty(GenericData* genData); |
821 |
> |
|
822 |
> |
/** |
823 |
> |
* Removes property from PropertyMap by name |
824 |
> |
* @param propName the name of property to be removed |
825 |
> |
*/ |
826 |
> |
void removeProperty(const std::string& propName); |
827 |
> |
|
828 |
> |
/** |
829 |
> |
* clear all of the properties |
830 |
> |
*/ |
831 |
> |
void clearProperties(); |
832 |
> |
|
833 |
> |
/** |
834 |
> |
* Returns all names of properties |
835 |
> |
* @return all names of properties |
836 |
> |
*/ |
837 |
> |
std::vector<std::string> getPropertyNames(); |
838 |
> |
|
839 |
> |
/** |
840 |
> |
* Returns all of the properties in PropertyMap |
841 |
> |
* @return all of the properties in PropertyMap |
842 |
> |
*/ |
843 |
> |
std::vector<GenericData*> getProperties(); |
844 |
> |
|
845 |
> |
/** |
846 |
> |
* Returns property |
847 |
> |
* @param propName name of property |
848 |
> |
* @return a pointer point to property with propName. If no property named propName |
849 |
> |
* exists, return NULL |
850 |
> |
*/ |
851 |
> |
GenericData* getPropertyByName(const std::string& propName); |
852 |
> |
|
853 |
> |
protected: |
854 |
> |
|
855 |
> |
StuntDouble(ObjectType objType, DataStoragePointer storage); |
856 |
> |
|
857 |
> |
StuntDouble(const StuntDouble& sd); |
858 |
> |
StuntDouble& operator=(const StuntDouble& sd); |
859 |
> |
|
860 |
> |
ObjectType objType_; |
861 |
> |
|
862 |
> |
bool linear_; |
863 |
> |
int linearAxis_; |
864 |
> |
|
865 |
> |
DataStoragePointer storage_; |
866 |
> |
SnapshotManager* snapshotMan_; |
867 |
> |
|
868 |
> |
int globalIndex_; |
869 |
> |
int localIndex_; |
870 |
> |
|
871 |
> |
private: |
872 |
> |
|
873 |
> |
std::string name_; |
874 |
> |
|
875 |
> |
double mass_; |
876 |
> |
|
877 |
> |
PropertyMap properties_; |
878 |
> |
}; |
879 |
> |
|
880 |
> |
}//end namespace oopse |
881 |
> |
#endif //PRIMITIVES_STUNTDOUBLE_HPP |