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