1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
< |
|
41 |
> |
|
42 |
|
#ifndef CONSTRAINTS_CONTRAINTELEM_HPP |
43 |
|
#define CONSTRAINTS_CONTRAINTELEM_HPP |
44 |
|
|
45 |
|
#include "primitives/StuntDouble.hpp" |
46 |
|
#include "utils/GenericData.hpp" |
47 |
|
#include "utils/simError.h" |
48 |
< |
namespace oopse { |
49 |
< |
|
50 |
< |
/** |
51 |
< |
* @class ConstraintElem ConstraintElem.hpp "constraints/ConstraintElem.hpp" |
52 |
< |
* An adapter class of StuntDouble which is used at constraint algorithm |
53 |
< |
*/ |
54 |
< |
|
55 |
< |
class ConstraintElem{ |
56 |
< |
public: |
57 |
< |
ConstraintElem(StuntDouble* sd) : sd_(sd) { |
58 |
< |
GenericData* movedData = sd_->getPropertyByName("Moved"); |
59 |
< |
if (movedData !=NULL) { //if generic data with keyword "moved" exists, assign it to moved_ |
60 |
< |
moved_ = dynamic_cast<BoolGenericData*>(movedData); |
61 |
< |
if (moved_ == NULL) { |
62 |
< |
sprintf(painCave.errMsg, |
63 |
< |
"Generic Data with keyword Moved exists, however, it can not be casted to a BoolGenericData.\n"); |
64 |
< |
painCave.isFatal = 1;; |
65 |
< |
simError(); |
66 |
< |
} |
67 |
< |
}else { //if generic data with keyword "moved" does not exist, create it |
68 |
< |
moved_ = new BoolGenericData("Moved"); |
69 |
< |
sd_->addProperty(moved_); |
70 |
< |
} |
71 |
< |
|
72 |
< |
GenericData* movingData = sd_->getPropertyByName("Moving"); |
73 |
< |
if (movingData !=NULL) { |
74 |
< |
moving_ = dynamic_cast<BoolGenericData*>(movingData); |
75 |
< |
if (moving_ == NULL) { |
76 |
< |
sprintf(painCave.errMsg, |
77 |
< |
"Generic Data with keyword Moving exists, however, it can not be casted to a BoolGenericData.\n"); |
78 |
< |
painCave.isFatal = 1;; |
79 |
< |
simError(); |
80 |
< |
} |
81 |
< |
}else { |
82 |
< |
moving_ = new BoolGenericData("Moving"); |
83 |
< |
sd_->addProperty(moving_); |
84 |
< |
} |
85 |
< |
|
86 |
< |
} |
87 |
< |
|
88 |
< |
bool getMoved() { return moved_->getData(); } |
89 |
< |
void setMoved(bool moved) { moved_->setData(moved);} |
90 |
< |
|
91 |
< |
bool getMoving() { return moving_->getData(); } |
92 |
< |
void setMoving(bool moving) { moving_->setData(moving); } |
93 |
< |
|
94 |
< |
StuntDouble* getStuntDouble() { return sd_; } |
95 |
< |
|
96 |
< |
/** |
97 |
< |
* Returns the global index of this stuntdouble. |
98 |
< |
* @return the global index of this stuntdouble |
99 |
< |
*/ |
100 |
< |
int getGlobalIndex() { |
101 |
< |
return sd_->getGlobalIndex(); |
102 |
< |
} |
103 |
< |
|
104 |
< |
/** |
105 |
< |
* Sets the global index of this stuntdouble. |
106 |
< |
* @param new global index to be set |
107 |
< |
*/ |
108 |
< |
void setGlobalIndex(int index) { |
109 |
< |
sd_->setGlobalIndex(index); |
110 |
< |
} |
111 |
< |
|
112 |
< |
/** |
113 |
< |
* Returns the local index of this stuntdouble |
114 |
< |
* @return the local index of this stuntdouble |
115 |
< |
*/ |
116 |
< |
int getLocalIndex() { |
117 |
< |
return sd_->getLocalIndex(); |
118 |
< |
} |
119 |
< |
|
120 |
< |
/** |
121 |
< |
* Sets the local index of this stuntdouble |
122 |
< |
* @param index new index to be set |
123 |
< |
*/ |
124 |
< |
void setLocalIndex(int index) { |
125 |
< |
sd_->setLocalIndex(index); |
126 |
< |
} |
127 |
< |
|
128 |
< |
/** |
129 |
< |
* Sets the Snapshot Manager of this stuntdouble |
130 |
< |
*/ |
131 |
< |
void setSnapshotManager(SnapshotManager* sman) { |
132 |
< |
sd_->setSnapshotManager(sman); |
133 |
< |
} |
134 |
< |
|
135 |
< |
/** |
136 |
< |
* Tests if this stuntdouble is an atom |
137 |
< |
* @return true is this stuntdouble is an atom(or a directional atom), return false otherwise |
138 |
< |
*/ |
139 |
< |
bool isAtom(){ |
140 |
< |
return sd_->isAtom(); |
141 |
< |
} |
142 |
< |
|
143 |
< |
/** |
144 |
< |
* Tests if this stuntdouble is an directional atom |
145 |
< |
* @return true if this stuntdouble is an directional atom, return false otherwise |
146 |
< |
*/ |
147 |
< |
bool isDirectionalAtom(){ |
148 |
< |
return sd_->isDirectional(); |
149 |
< |
} |
150 |
< |
|
151 |
< |
/** |
152 |
< |
* Tests if this stuntdouble is a rigid body. |
153 |
< |
* @return true if this stuntdouble is a rigid body, otherwise return false |
154 |
< |
*/ |
155 |
< |
bool isRigidBody(){ |
156 |
< |
return sd_->isRigidBody(); |
157 |
< |
} |
158 |
< |
|
159 |
< |
/** |
160 |
< |
* Tests if this stuntdouble is a directional one. |
161 |
< |
* @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise |
162 |
< |
*/ |
163 |
< |
bool isDirectional(){ |
164 |
< |
return sd_->isDirectional(); |
165 |
< |
} |
166 |
< |
|
167 |
< |
/** |
168 |
< |
* Returns the previous position of this stuntdouble |
169 |
< |
* @return the position of this stuntdouble |
170 |
< |
*/ |
171 |
< |
Vector3d getPrevPos() { |
172 |
< |
return sd_->getPrevPos(); |
173 |
< |
} |
174 |
< |
|
175 |
< |
/** |
176 |
< |
* Returns the current position of this stuntdouble |
177 |
< |
* @return the position of this stuntdouble |
178 |
< |
*/ |
179 |
< |
Vector3d getPos() { |
180 |
< |
return sd_->getPos(); |
181 |
< |
} |
182 |
< |
|
183 |
< |
/** |
184 |
< |
* Returns the position of this stuntdouble in specified snapshot |
185 |
< |
* @return the position of this stuntdouble |
186 |
< |
* @param snapshotNo |
187 |
< |
*/ |
188 |
< |
Vector3d getPos(int snapshotNo) { |
189 |
< |
return sd_->getPos(snapshotNo); |
190 |
< |
} |
191 |
< |
|
192 |
< |
/** |
193 |
< |
* Sets the previous position of this stuntdouble |
194 |
< |
* @param pos new position |
195 |
< |
* @see #getPos |
196 |
< |
*/ |
197 |
< |
void setPrevPos(const Vector3d& pos) { |
198 |
< |
sd_->setPrevPos(pos); |
199 |
< |
} |
200 |
< |
|
201 |
< |
/** |
202 |
< |
* Sets the current position of this stuntdouble |
203 |
< |
* @param pos new position |
204 |
< |
*/ |
205 |
< |
void setPos(const Vector3d& pos) { |
206 |
< |
sd_->setPos(pos); |
207 |
< |
} |
208 |
< |
|
209 |
< |
/** |
210 |
< |
* Sets the position of this stuntdouble in specified snapshot |
211 |
< |
* @param pos position to be set |
212 |
< |
* @param snapshotNo |
213 |
< |
* @see #getPos |
214 |
< |
*/ |
215 |
< |
void setPos(const Vector3d& pos, int snapshotNo) { |
216 |
< |
sd_->setPos(pos, snapshotNo); |
217 |
< |
} |
218 |
< |
|
219 |
< |
/** |
220 |
< |
* Returns the previous velocity of this stuntdouble |
221 |
< |
* @return the velocity of this stuntdouble |
222 |
< |
*/ |
223 |
< |
Vector3d getPrevVel() { |
224 |
< |
return sd_->getPrevVel(); |
225 |
< |
} |
226 |
< |
|
227 |
< |
/** |
228 |
< |
* Returns the current velocity of this stuntdouble |
229 |
< |
* @return the velocity of this stuntdouble |
230 |
< |
*/ |
231 |
< |
Vector3d getVel() { |
232 |
< |
return sd_->getVel(); |
233 |
< |
} |
234 |
< |
|
235 |
< |
/** |
236 |
< |
* Returns the velocity of this stuntdouble in specified snapshot |
237 |
< |
* @return the velocity of this stuntdouble |
238 |
< |
* @param snapshotNo |
239 |
< |
*/ |
240 |
< |
|
241 |
< |
Vector3d getVel(int snapshotNo) { |
242 |
< |
return sd_->getVel(snapshotNo); |
243 |
< |
} |
244 |
< |
|
245 |
< |
/** |
246 |
< |
* Sets the previous velocity of this stuntdouble |
247 |
< |
* @param vel new velocity |
248 |
< |
* @see #getVel |
249 |
< |
*/ |
250 |
< |
void setPrevVel(const Vector3d& vel) { |
251 |
< |
sd_->setPrevVel(vel); |
252 |
< |
} |
253 |
< |
|
254 |
< |
/** |
255 |
< |
* Sets the current velocity of this stuntdouble |
256 |
< |
* @param vel new velocity |
257 |
< |
*/ |
258 |
< |
void setVel(const Vector3d& vel) { |
259 |
< |
sd_->setVel(vel); |
260 |
< |
} |
261 |
< |
|
262 |
< |
/** |
263 |
< |
* Sets the velocity of this stuntdouble in specified snapshot |
264 |
< |
* @param vel velocity to be set |
265 |
< |
* @param snapshotNo |
266 |
< |
* @see #getVel |
267 |
< |
*/ |
268 |
< |
void setVel(const Vector3d& vel, int snapshotNo) { |
269 |
< |
sd_->setVel(vel, snapshotNo); |
270 |
< |
} |
271 |
< |
|
272 |
< |
/** |
273 |
< |
* Returns the previous rotation matrix of this stuntdouble |
274 |
< |
* @return the rotation matrix of this stuntdouble |
275 |
< |
*/ |
276 |
< |
RotMat3x3d getPrevA() { |
277 |
< |
return sd_->getPrevA(); |
278 |
< |
} |
279 |
< |
|
280 |
< |
/** |
281 |
< |
* Returns the current rotation matrix of this stuntdouble |
282 |
< |
* @return the rotation matrix of this stuntdouble |
283 |
< |
*/ |
284 |
< |
RotMat3x3d getA() { |
285 |
< |
return sd_->getA(); |
286 |
< |
} |
287 |
< |
|
288 |
< |
/** |
289 |
< |
* Returns the rotation matrix of this stuntdouble in specified snapshot |
290 |
< |
* |
291 |
< |
* @return the rotation matrix of this stuntdouble |
292 |
< |
* @param snapshotNo |
293 |
< |
*/ |
294 |
< |
RotMat3x3d getA(int snapshotNo) { |
295 |
< |
return sd_->getA(snapshotNo); |
296 |
< |
} |
297 |
< |
|
298 |
< |
/** |
299 |
< |
* Sets the previous rotation matrix of this stuntdouble |
300 |
< |
* @param a new rotation matrix |
301 |
< |
* @see #getA |
302 |
< |
*/ |
303 |
< |
void setPrevA(const RotMat3x3d& a) { |
304 |
< |
sd_->setPrevA(a); |
305 |
< |
} |
306 |
< |
|
307 |
< |
/** |
308 |
< |
* Sets the current rotation matrix of this stuntdouble |
309 |
< |
* @param a new rotation matrix |
310 |
< |
*/ |
311 |
< |
void setA(const RotMat3x3d& a) { |
312 |
< |
sd_->setA(a); |
313 |
< |
} |
314 |
< |
|
315 |
< |
/** |
316 |
< |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
317 |
< |
* @param a rotation matrix to be set |
318 |
< |
* @param snapshotNo |
319 |
< |
* @see #getA |
320 |
< |
*/ |
321 |
< |
void setA(const RotMat3x3d& a, int snapshotNo) { |
322 |
< |
sd_->setA(a, snapshotNo); |
323 |
< |
} |
324 |
< |
|
325 |
< |
/** |
326 |
< |
* Returns the previous angular momentum of this stuntdouble (body-fixed). |
327 |
< |
* @return the angular momentum of this stuntdouble |
328 |
< |
*/ |
329 |
< |
Vector3d getPrevJ() { |
330 |
< |
return sd_->getPrevJ(); |
331 |
< |
} |
332 |
< |
|
333 |
< |
/** |
334 |
< |
* Returns the current angular momentum of this stuntdouble (body -fixed). |
335 |
< |
* @return the angular momentum of this stuntdouble |
336 |
< |
*/ |
337 |
< |
Vector3d getJ() { |
338 |
< |
return sd_->getJ(); |
339 |
< |
} |
340 |
< |
|
341 |
< |
/** |
342 |
< |
* Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed). |
343 |
< |
* @return the angular momentum of this stuntdouble |
344 |
< |
* @param snapshotNo |
345 |
< |
*/ |
346 |
< |
Vector3d getJ(int snapshotNo) { |
347 |
< |
return sd_->getJ(snapshotNo); |
348 |
< |
} |
349 |
< |
|
350 |
< |
/** |
351 |
< |
* Sets the previous angular momentum of this stuntdouble (body-fixed). |
352 |
< |
* @param angMom new angular momentum |
353 |
< |
* @see #getJ |
354 |
< |
*/ |
355 |
< |
void setPrevJ(const Vector3d& angMom) { |
356 |
< |
sd_->setPrevJ(angMom); |
357 |
< |
} |
358 |
< |
|
359 |
< |
/** |
360 |
< |
* Sets the current angular momentum of this stuntdouble (body-fixed). |
361 |
< |
* @param angMom new angular momentum |
362 |
< |
*/ |
363 |
< |
void setJ(const Vector3d& angMom) { |
364 |
< |
sd_->setJ(angMom); |
365 |
< |
} |
366 |
< |
|
367 |
< |
/** |
368 |
< |
* Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed). |
369 |
< |
* @param angMom angular momentum to be set |
370 |
< |
* @param snapshotNo |
371 |
< |
* @see #getJ |
372 |
< |
*/ |
373 |
< |
void setJ(const Vector3d& angMom, int snapshotNo) { |
374 |
< |
sd_->setJ(angMom, snapshotNo); |
375 |
< |
} |
376 |
< |
|
377 |
< |
/** |
378 |
< |
* Returns the previous quaternion of this stuntdouble |
379 |
< |
* @return the quaternion of this stuntdouble |
380 |
< |
*/ |
381 |
< |
Quat4d getPrevQ() { |
382 |
< |
return sd_->getPrevQ(); |
383 |
< |
} |
384 |
< |
|
385 |
< |
/** |
386 |
< |
* Returns the current quaternion of this stuntdouble |
387 |
< |
* @return the quaternion of this stuntdouble |
388 |
< |
*/ |
389 |
< |
Quat4d getQ() { |
390 |
< |
return sd_->getQ(); |
391 |
< |
} |
392 |
< |
|
393 |
< |
/** |
394 |
< |
* Returns the quaternion of this stuntdouble in specified snapshot |
395 |
< |
* @return the quaternion of this stuntdouble |
396 |
< |
* @param snapshotNo |
397 |
< |
*/ |
398 |
< |
Quat4d getQ(int snapshotNo) { |
399 |
< |
return sd_->getQ(snapshotNo); |
400 |
< |
} |
401 |
< |
|
402 |
< |
/** |
403 |
< |
* Sets the previous quaternion of this stuntdouble |
404 |
< |
* @param q new quaternion |
405 |
< |
* @note actual storage data is rotation matrix |
406 |
< |
*/ |
407 |
< |
void setPrevQ(const Quat4d& q) { |
408 |
< |
sd_->setPrevQ(q); |
409 |
< |
} |
410 |
< |
|
411 |
< |
/** |
412 |
< |
* Sets the current quaternion of this stuntdouble |
413 |
< |
* @param q new quaternion |
414 |
< |
* @note actual storage data is rotation matrix |
415 |
< |
*/ |
416 |
< |
void setQ(const Quat4d& q) { |
417 |
< |
sd_->setQ(q); |
418 |
< |
} |
419 |
< |
|
420 |
< |
/** |
421 |
< |
* Sets the quaternion of this stuntdouble in specified snapshot |
422 |
< |
* |
423 |
< |
* @param q quaternion to be set |
424 |
< |
* @param snapshotNo |
425 |
< |
* @note actual storage data is rotation matrix |
426 |
< |
*/ |
427 |
< |
void setQ(const Quat4d& q, int snapshotNo) { |
428 |
< |
sd_->setQ(q, snapshotNo); |
429 |
< |
} |
430 |
< |
|
431 |
< |
/** |
432 |
< |
* Returns the previous euler angles of this stuntdouble |
433 |
< |
* @return the euler angles of this stuntdouble |
434 |
< |
*/ |
435 |
< |
Vector3d getPrevEuler() { |
436 |
< |
return sd_->getPrevEuler(); |
437 |
< |
} |
438 |
< |
|
439 |
< |
/** |
440 |
< |
* Returns the current euler angles of this stuntdouble |
441 |
< |
* @return the euler angles of this stuntdouble |
442 |
< |
*/ |
443 |
< |
Vector3d getEuler() { |
444 |
< |
return sd_->getEuler(); |
445 |
< |
} |
446 |
< |
|
447 |
< |
/** |
448 |
< |
* Returns the euler angles of this stuntdouble in specified snapshot. |
449 |
< |
* @return the euler angles of this stuntdouble |
450 |
< |
* @param snapshotNo |
451 |
< |
*/ |
452 |
< |
Vector3d getEuler(int snapshotNo) { |
453 |
< |
return sd_->getEuler(snapshotNo); |
454 |
< |
} |
455 |
< |
|
456 |
< |
/** |
457 |
< |
* Sets the previous euler angles of this stuntdouble. |
458 |
< |
* @param euler new euler angles |
459 |
< |
* @see #getEuler |
460 |
< |
* @note actual storage data is rotation matrix |
461 |
< |
*/ |
462 |
< |
void setPrevEuler(const Vector3d& euler) { |
463 |
< |
sd_->setPrevEuler(euler); |
464 |
< |
} |
465 |
< |
|
466 |
< |
/** |
467 |
< |
* Sets the current euler angles of this stuntdouble |
468 |
< |
* @param euler new euler angles |
469 |
< |
*/ |
470 |
< |
void setEuler(const Vector3d& euler) { |
471 |
< |
sd_->setEuler(euler); |
472 |
< |
} |
473 |
< |
|
474 |
< |
/** |
475 |
< |
* Sets the euler angles of this stuntdouble in specified snapshot |
476 |
< |
* |
477 |
< |
* @param euler euler angles to be set |
478 |
< |
* @param snapshotNo |
479 |
< |
* @note actual storage data is rotation matrix |
480 |
< |
*/ |
481 |
< |
void setEuler(const Vector3d& euler, int snapshotNo) { |
482 |
< |
sd_->setEuler(euler, snapshotNo); |
483 |
< |
} |
484 |
< |
|
485 |
< |
/** |
486 |
< |
* Returns the previous unit vectors of this stuntdouble |
487 |
< |
* @return the unit vectors of this stuntdouble |
488 |
< |
*/ |
489 |
< |
RotMat3x3d getPrevElectroFrame() { |
490 |
< |
return sd_->getPrevElectroFrame(); |
491 |
< |
} |
492 |
< |
|
493 |
< |
/** |
494 |
< |
* Returns the current unit vectors of this stuntdouble |
495 |
< |
* @return the unit vectors of this stuntdouble |
496 |
< |
*/ |
497 |
< |
RotMat3x3d getElectroFrame() { |
498 |
< |
return sd_->getElectroFrame(); |
499 |
< |
} |
500 |
< |
|
501 |
< |
/** |
502 |
< |
* Returns the unit vectors of this stuntdouble in specified snapshot |
503 |
< |
* |
504 |
< |
* @return the unit vectors of this stuntdouble |
505 |
< |
* @param snapshotNo |
506 |
< |
*/ |
507 |
< |
RotMat3x3d getElectroFrame(int snapshotNo) { |
508 |
< |
return sd_->getElectroFrame(snapshotNo); |
509 |
< |
} |
510 |
< |
|
511 |
< |
/** |
512 |
< |
* Returns the previous force of this stuntdouble |
513 |
< |
* @return the force of this stuntdouble |
514 |
< |
*/ |
515 |
< |
Vector3d getPrevFrc() { |
516 |
< |
return sd_->getPrevFrc(); |
517 |
< |
} |
518 |
< |
|
519 |
< |
/** |
520 |
< |
* Returns the current force of this stuntdouble |
521 |
< |
* @return the force of this stuntdouble |
522 |
< |
*/ |
523 |
< |
Vector3d getFrc() { |
524 |
< |
return sd_->getFrc(); |
525 |
< |
} |
526 |
< |
|
527 |
< |
/** |
528 |
< |
* Returns the force of this stuntdouble in specified snapshot |
529 |
< |
* |
530 |
< |
* @return the force of this stuntdouble |
531 |
< |
* @param snapshotNo |
532 |
< |
*/ |
533 |
< |
Vector3d getFrc(int snapshotNo) { |
534 |
< |
return sd_->getFrc(snapshotNo); |
535 |
< |
} |
536 |
< |
|
537 |
< |
/** |
538 |
< |
* Sets the previous force of this stuntdouble |
539 |
< |
* |
540 |
< |
* @param frc new force |
541 |
< |
* @see #getFrc |
542 |
< |
*/ |
543 |
< |
void setPrevFrc(const Vector3d& frc) { |
544 |
< |
sd_->setPrevFrc(frc); |
545 |
< |
} |
546 |
< |
|
547 |
< |
/** |
548 |
< |
* Sets the current force of this stuntdouble |
549 |
< |
* @param frc new force |
550 |
< |
*/ |
551 |
< |
void setFrc(const Vector3d& frc) { |
552 |
< |
sd_->setFrc(frc); |
553 |
< |
} |
554 |
< |
|
555 |
< |
/** |
556 |
< |
* Sets the force of this stuntdouble in specified snapshot |
557 |
< |
* |
558 |
< |
* @param frc force to be set |
559 |
< |
* @param snapshotNo |
560 |
< |
* @see #getFrc |
561 |
< |
*/ |
562 |
< |
void setFrc(const Vector3d& frc, int snapshotNo) { |
563 |
< |
sd_->setFrc(frc, snapshotNo); |
564 |
< |
} |
565 |
< |
|
566 |
< |
/** |
567 |
< |
* Adds force into the previous force of this stuntdouble |
568 |
< |
* |
569 |
< |
* @param frc new force |
570 |
< |
* @see #getFrc |
571 |
< |
*/ |
572 |
< |
void addPrevFrc(const Vector3d& frc) { |
573 |
< |
sd_->addPrevFrc(frc); |
574 |
< |
} |
575 |
< |
|
576 |
< |
/** |
577 |
< |
* Adds force into the current force of this stuntdouble |
578 |
< |
* @param frc new force |
579 |
< |
*/ |
580 |
< |
void addFrc(const Vector3d& frc) { |
581 |
< |
sd_->addFrc(frc); |
582 |
< |
} |
583 |
< |
|
584 |
< |
/** |
585 |
< |
* Adds force into the force of this stuntdouble in specified snapshot |
586 |
< |
* |
587 |
< |
* @param frc force to be set |
588 |
< |
* @param snapshotNo |
589 |
< |
* @see #getFrc |
590 |
< |
*/ |
591 |
< |
void addFrc(const Vector3d& frc, int snapshotNo) { |
592 |
< |
sd_->addFrc(frc, snapshotNo); |
593 |
< |
} |
594 |
< |
|
595 |
< |
/** |
596 |
< |
* Returns the previous torque of this stuntdouble |
597 |
< |
* @return the torque of this stuntdouble |
598 |
< |
*/ |
599 |
< |
Vector3d getPrevTrq() { |
600 |
< |
return sd_->getPrevTrq(); |
601 |
< |
} |
602 |
< |
|
603 |
< |
/** |
604 |
< |
* Returns the current torque of this stuntdouble |
605 |
< |
* @return the torque of this stuntdouble |
606 |
< |
*/ |
607 |
< |
Vector3d getTrq() { |
608 |
< |
return sd_->getTrq(); |
609 |
< |
} |
610 |
< |
|
611 |
< |
/** |
612 |
< |
* Returns the torque of this stuntdouble in specified snapshot |
613 |
< |
* |
614 |
< |
* @return the torque of this stuntdouble |
615 |
< |
* @param snapshotNo |
616 |
< |
*/ |
617 |
< |
Vector3d getTrq(int snapshotNo) { |
618 |
< |
return sd_->getTrq(snapshotNo); |
619 |
< |
} |
620 |
< |
|
621 |
< |
/** |
622 |
< |
* Sets the previous torque of this stuntdouble |
623 |
< |
* |
624 |
< |
* @param trq new torque |
625 |
< |
* @see #getTrq |
626 |
< |
*/ |
627 |
< |
void setPrevTrq(const Vector3d& trq) { |
628 |
< |
sd_->setPrevTrq(trq); |
629 |
< |
} |
630 |
< |
|
631 |
< |
/** |
632 |
< |
* Sets the current torque of this stuntdouble |
633 |
< |
* @param trq new torque |
634 |
< |
*/ |
635 |
< |
void setTrq(const Vector3d& trq) { |
636 |
< |
sd_->setTrq(trq); |
637 |
< |
} |
638 |
< |
|
639 |
< |
/** |
640 |
< |
* Sets the torque of this stuntdouble in specified snapshot |
641 |
< |
* |
642 |
< |
* @param trq torque to be set |
643 |
< |
* @param snapshotNo |
644 |
< |
* @see #getTrq |
645 |
< |
*/ |
646 |
< |
void setTrq(const Vector3d& trq, int snapshotNo) { |
647 |
< |
sd_->setTrq(trq, snapshotNo); |
648 |
< |
} |
649 |
< |
|
650 |
< |
/** |
651 |
< |
* Adds torque into the previous torque of this stuntdouble |
652 |
< |
* |
653 |
< |
* @param trq new torque |
654 |
< |
* @see #getTrq |
655 |
< |
*/ |
656 |
< |
void addPrevTrq(const Vector3d& trq) { |
657 |
< |
sd_->addPrevTrq(trq); |
658 |
< |
} |
659 |
< |
|
660 |
< |
/** |
661 |
< |
* Adds torque into the current torque of this stuntdouble |
662 |
< |
* @param trq new torque |
663 |
< |
*/ |
664 |
< |
void addTrq(const Vector3d& trq) { |
665 |
< |
sd_->addTrq(trq); |
666 |
< |
} |
667 |
< |
|
668 |
< |
/** |
669 |
< |
* Adds torque into the torque of this stuntdouble in specified snapshot |
670 |
< |
* |
671 |
< |
* @param trq torque to be add |
672 |
< |
* @param snapshotNo |
673 |
< |
* @see #getTrq |
674 |
< |
*/ |
675 |
< |
void addTrq(const Vector3d& trq, int snapshotNo) { |
676 |
< |
sd_->addTrq(trq, snapshotNo); |
677 |
< |
} |
48 |
> |
namespace OpenMD { |
49 |
> |
|
50 |
> |
/** |
51 |
> |
* @class ConstraintElem ConstraintElem.hpp "constraints/ConstraintElem.hpp" |
52 |
> |
* An adapter class of StuntDouble which is used at constraint algorithm |
53 |
> |
*/ |
54 |
> |
|
55 |
> |
class ConstraintElem{ |
56 |
> |
public: |
57 |
> |
ConstraintElem(StuntDouble* sd) : sd_(sd) { |
58 |
> |
GenericData* movedData = sd_->getPropertyByName("Moved"); |
59 |
> |
if (movedData !=NULL) { //if generic data with keyword "moved" exists, assign it to moved_ |
60 |
> |
moved_ = dynamic_cast<BoolGenericData*>(movedData); |
61 |
> |
if (moved_ == NULL) { |
62 |
> |
sprintf(painCave.errMsg, |
63 |
> |
"Generic Data with keyword Moved exists, however, it can not be casted to a BoolGenericData.\n"); |
64 |
> |
painCave.isFatal = 1;; |
65 |
> |
simError(); |
66 |
> |
} |
67 |
> |
}else { //if generic data with keyword "moved" does not exist, create it |
68 |
> |
moved_ = new BoolGenericData("Moved"); |
69 |
> |
sd_->addProperty(moved_); |
70 |
> |
} |
71 |
|
|
72 |
< |
/** Set the force of this stuntdouble to zero */ |
73 |
< |
void zeroForcesAndTorques() { |
74 |
< |
sd_->zeroForcesAndTorques(); |
75 |
< |
} |
76 |
< |
/** |
77 |
< |
* Returns the inertia tensor of this stuntdouble |
78 |
< |
* @return the inertia tensor of this stuntdouble |
79 |
< |
*/ |
80 |
< |
Mat3x3d getI() { |
81 |
< |
return sd_->getI(); |
82 |
< |
} |
83 |
< |
|
84 |
< |
/** |
85 |
< |
* Returns the gradient of this stuntdouble |
86 |
< |
* @return the gradient of this stuntdouble |
87 |
< |
*/ |
88 |
< |
std::vector<double> getGrad() { |
89 |
< |
return sd_->getGrad(); |
90 |
< |
} |
91 |
< |
|
92 |
< |
/** |
93 |
< |
* Tests the if this stuntdouble is a linear rigidbody |
94 |
< |
* |
95 |
< |
* @return true if this stuntdouble is a linear rigidbody, otherwise return false |
96 |
< |
* @note atom and directional atom will always return false |
97 |
< |
* |
98 |
< |
* @see #linearAxis |
99 |
< |
*/ |
100 |
< |
bool isLinear() { |
101 |
< |
return sd_->isLinear(); |
102 |
< |
} |
103 |
< |
|
104 |
< |
/** |
105 |
< |
* Returns the linear axis of the rigidbody, atom and directional atom will always return -1 |
106 |
< |
* |
107 |
< |
* @return the linear axis of the rigidbody |
108 |
< |
* |
109 |
< |
* @see #isLinear |
110 |
< |
*/ |
111 |
< |
int linearAxis() { |
112 |
< |
return sd_->linearAxis(); |
113 |
< |
} |
114 |
< |
|
115 |
< |
/** Returns the mass of this stuntdouble */ |
116 |
< |
double getMass() { |
117 |
< |
return sd_->getMass(); |
118 |
< |
} |
119 |
< |
|
120 |
< |
/** |
121 |
< |
* Sets the mass of this stuntdoulbe |
122 |
< |
* @param mass the mass to be set |
123 |
< |
*/ |
124 |
< |
void setMass(double mass) { |
125 |
< |
sd_->setMass(mass); |
126 |
< |
} |
127 |
< |
|
128 |
< |
/** Returns the name of this stuntdouble */ |
129 |
< |
std::string getType() { |
130 |
< |
return sd_->getType(); |
131 |
< |
} |
132 |
< |
|
133 |
< |
/** Sets the name of this stuntdouble*/ |
134 |
< |
void setType(const std::string& name) { |
135 |
< |
sd_->setType(name); |
136 |
< |
} |
137 |
< |
|
138 |
< |
/** |
139 |
< |
* Converts a lab fixed vector to a body fixed vector. |
140 |
< |
* @return body fixed vector |
141 |
< |
* @param v lab fixed vector |
142 |
< |
*/ |
143 |
< |
Vector3d lab2Body(const Vector3d& v) { |
144 |
< |
return sd_->lab2Body(v); |
145 |
< |
} |
146 |
< |
|
147 |
< |
/** |
148 |
< |
* Converts a body fixed vector to a lab fixed vector. |
149 |
< |
* @return corresponding lab fixed vector |
150 |
< |
* @param v body fixed vector |
151 |
< |
*/ |
152 |
< |
Vector3d body2Lab(const Vector3d& v){ |
153 |
< |
return sd_->body2Lab(v); |
154 |
< |
} |
155 |
< |
/** |
156 |
< |
* <p> |
157 |
< |
* The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on |
158 |
< |
* the elements of a data structure. In this way, you can change the operation being performed |
159 |
< |
* on a structure without the need of changing the classes of the elements that you are operating |
160 |
< |
* on. Using a Visitor pattern allows you to decouple the classes for the data structure and the |
161 |
< |
* algorithms used upon them |
162 |
< |
* </p> |
163 |
< |
* @param v visitor |
164 |
< |
*/ |
165 |
< |
void accept(BaseVisitor* v) { |
166 |
< |
sd_->accept(v); |
167 |
< |
} |
168 |
< |
|
169 |
< |
//below functions are just forward functions |
170 |
< |
/** |
171 |
< |
* Adds property into property map |
172 |
< |
* @param genData GenericData to be added into PropertyMap |
173 |
< |
*/ |
174 |
< |
void addProperty(GenericData* genData){ |
175 |
< |
sd_->addProperty(genData); |
176 |
< |
} |
177 |
< |
|
178 |
< |
/** |
179 |
< |
* Removes property from PropertyMap by name |
180 |
< |
* @param propName the name of property to be removed |
181 |
< |
*/ |
182 |
< |
void removeProperty(const std::string& propName) { |
183 |
< |
sd_->removeProperty(propName); |
184 |
< |
} |
185 |
< |
|
186 |
< |
/** |
187 |
< |
* clear all of the properties |
188 |
< |
*/ |
189 |
< |
void clearProperties() { |
190 |
< |
sd_->clearProperties(); |
191 |
< |
} |
192 |
< |
|
193 |
< |
/** |
194 |
< |
* Returns all names of properties |
195 |
< |
* @return all names of properties |
196 |
< |
*/ |
197 |
< |
std::vector<std::string> getPropertyNames() { |
198 |
< |
return sd_->getPropertyNames(); |
199 |
< |
} |
200 |
< |
|
201 |
< |
/** |
202 |
< |
* Returns all of the properties in PropertyMap |
203 |
< |
* @return all of the properties in PropertyMap |
204 |
< |
*/ |
205 |
< |
std::vector<GenericData*> getProperties() { |
206 |
< |
return sd_->getProperties(); |
207 |
< |
} |
208 |
< |
|
209 |
< |
/** |
210 |
< |
* Returns property |
211 |
< |
* @param propName name of property |
212 |
< |
* @return a pointer point to property with propName. If no property named propName |
213 |
< |
* exists, return NULL |
214 |
< |
*/ |
215 |
< |
GenericData* getPropertyByName(const std::string& propName) { |
216 |
< |
return sd_->getPropertyByName(propName); |
217 |
< |
} |
218 |
< |
|
219 |
< |
private: |
220 |
< |
StuntDouble* sd_; |
221 |
< |
BoolGenericData* moved_; |
222 |
< |
BoolGenericData* moving_; |
223 |
< |
}; |
224 |
< |
|
72 |
> |
GenericData* movingData = sd_->getPropertyByName("Moving"); |
73 |
> |
if (movingData !=NULL) { |
74 |
> |
moving_ = dynamic_cast<BoolGenericData*>(movingData); |
75 |
> |
if (moving_ == NULL) { |
76 |
> |
sprintf(painCave.errMsg, |
77 |
> |
"Generic Data with keyword Moving exists, however, it can not be casted to a BoolGenericData.\n"); |
78 |
> |
painCave.isFatal = 1;; |
79 |
> |
simError(); |
80 |
> |
} |
81 |
> |
}else { |
82 |
> |
moving_ = new BoolGenericData("Moving"); |
83 |
> |
sd_->addProperty(moving_); |
84 |
> |
} |
85 |
> |
|
86 |
> |
} |
87 |
> |
|
88 |
> |
bool getMoved() { return moved_->getData(); } |
89 |
> |
void setMoved(bool moved) { moved_->setData(moved);} |
90 |
> |
|
91 |
> |
bool getMoving() { return moving_->getData(); } |
92 |
> |
void setMoving(bool moving) { moving_->setData(moving); } |
93 |
> |
|
94 |
> |
StuntDouble* getStuntDouble() { return sd_; } |
95 |
> |
|
96 |
> |
/** |
97 |
> |
* Returns the global index of this stuntRealType. |
98 |
> |
* @return the global index of this stuntdouble |
99 |
> |
*/ |
100 |
> |
int getGlobalIndex() { |
101 |
> |
return sd_->getGlobalIndex(); |
102 |
> |
} |
103 |
> |
|
104 |
> |
/** |
105 |
> |
* Sets the global index of this stuntRealType. |
106 |
> |
* @param new global index to be set |
107 |
> |
*/ |
108 |
> |
void setGlobalIndex(int index) { |
109 |
> |
sd_->setGlobalIndex(index); |
110 |
> |
} |
111 |
> |
|
112 |
> |
/** |
113 |
> |
* Returns the local index of this stuntdouble |
114 |
> |
* @return the local index of this stuntdouble |
115 |
> |
*/ |
116 |
> |
int getLocalIndex() { |
117 |
> |
return sd_->getLocalIndex(); |
118 |
> |
} |
119 |
> |
|
120 |
> |
/** |
121 |
> |
* Sets the local index of this stuntdouble |
122 |
> |
* @param index new index to be set |
123 |
> |
*/ |
124 |
> |
void setLocalIndex(int index) { |
125 |
> |
sd_->setLocalIndex(index); |
126 |
> |
} |
127 |
> |
|
128 |
> |
/** |
129 |
> |
* Sets the Snapshot Manager of this stuntdouble |
130 |
> |
*/ |
131 |
> |
void setSnapshotManager(SnapshotManager* sman) { |
132 |
> |
sd_->setSnapshotManager(sman); |
133 |
> |
} |
134 |
> |
|
135 |
> |
/** |
136 |
> |
* Tests if this stuntdouble is an atom |
137 |
> |
* @return true is this stuntdouble is an atom(or a directional atom), return false otherwise |
138 |
> |
*/ |
139 |
> |
bool isAtom(){ |
140 |
> |
return sd_->isAtom(); |
141 |
> |
} |
142 |
> |
|
143 |
> |
/** |
144 |
> |
* Tests if this stuntdouble is an directional atom |
145 |
> |
* @return true if this stuntdouble is an directional atom, return false otherwise |
146 |
> |
*/ |
147 |
> |
bool isDirectionalAtom(){ |
148 |
> |
return sd_->isDirectional(); |
149 |
> |
} |
150 |
> |
|
151 |
> |
/** |
152 |
> |
* Tests if this stuntdouble is a rigid body. |
153 |
> |
* @return true if this stuntdouble is a rigid body, otherwise return false |
154 |
> |
*/ |
155 |
> |
bool isRigidBody(){ |
156 |
> |
return sd_->isRigidBody(); |
157 |
> |
} |
158 |
> |
|
159 |
> |
/** |
160 |
> |
* Tests if this stuntdouble is a directional one. |
161 |
> |
* @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise |
162 |
> |
*/ |
163 |
> |
bool isDirectional(){ |
164 |
> |
return sd_->isDirectional(); |
165 |
> |
} |
166 |
> |
|
167 |
> |
/** |
168 |
> |
* Returns the previous position of this stuntdouble |
169 |
> |
* @return the position of this stuntdouble |
170 |
> |
*/ |
171 |
> |
Vector3d getPrevPos() { |
172 |
> |
return sd_->getPrevPos(); |
173 |
> |
} |
174 |
> |
|
175 |
> |
/** |
176 |
> |
* Returns the current position of this stuntdouble |
177 |
> |
* @return the position of this stuntdouble |
178 |
> |
*/ |
179 |
> |
Vector3d getPos() { |
180 |
> |
return sd_->getPos(); |
181 |
> |
} |
182 |
> |
|
183 |
> |
/** |
184 |
> |
* Returns the position of this stuntdouble in specified snapshot |
185 |
> |
* @return the position of this stuntdouble |
186 |
> |
* @param snapshotNo |
187 |
> |
*/ |
188 |
> |
Vector3d getPos(int snapshotNo) { |
189 |
> |
return sd_->getPos(snapshotNo); |
190 |
> |
} |
191 |
> |
|
192 |
> |
/** |
193 |
> |
* Sets the previous position of this stuntdouble |
194 |
> |
* @param pos new position |
195 |
> |
* @see #getPos |
196 |
> |
*/ |
197 |
> |
void setPrevPos(const Vector3d& pos) { |
198 |
> |
sd_->setPrevPos(pos); |
199 |
> |
} |
200 |
> |
|
201 |
> |
/** |
202 |
> |
* Sets the current position of this stuntdouble |
203 |
> |
* @param pos new position |
204 |
> |
*/ |
205 |
> |
void setPos(const Vector3d& pos) { |
206 |
> |
sd_->setPos(pos); |
207 |
> |
} |
208 |
> |
|
209 |
> |
/** |
210 |
> |
* Sets the position of this stuntdouble in specified snapshot |
211 |
> |
* @param pos position to be set |
212 |
> |
* @param snapshotNo |
213 |
> |
* @see #getPos |
214 |
> |
*/ |
215 |
> |
void setPos(const Vector3d& pos, int snapshotNo) { |
216 |
> |
sd_->setPos(pos, snapshotNo); |
217 |
> |
} |
218 |
> |
|
219 |
> |
/** |
220 |
> |
* Returns the previous velocity of this stuntdouble |
221 |
> |
* @return the velocity of this stuntdouble |
222 |
> |
*/ |
223 |
> |
Vector3d getPrevVel() { |
224 |
> |
return sd_->getPrevVel(); |
225 |
> |
} |
226 |
> |
|
227 |
> |
/** |
228 |
> |
* Returns the current velocity of this stuntdouble |
229 |
> |
* @return the velocity of this stuntdouble |
230 |
> |
*/ |
231 |
> |
Vector3d getVel() { |
232 |
> |
return sd_->getVel(); |
233 |
> |
} |
234 |
> |
|
235 |
> |
/** |
236 |
> |
* Returns the velocity of this stuntdouble in specified snapshot |
237 |
> |
* @return the velocity of this stuntdouble |
238 |
> |
* @param snapshotNo |
239 |
> |
*/ |
240 |
> |
|
241 |
> |
Vector3d getVel(int snapshotNo) { |
242 |
> |
return sd_->getVel(snapshotNo); |
243 |
> |
} |
244 |
> |
|
245 |
> |
/** |
246 |
> |
* Sets the previous velocity of this stuntdouble |
247 |
> |
* @param vel new velocity |
248 |
> |
* @see #getVel |
249 |
> |
*/ |
250 |
> |
void setPrevVel(const Vector3d& vel) { |
251 |
> |
sd_->setPrevVel(vel); |
252 |
> |
} |
253 |
> |
|
254 |
> |
/** |
255 |
> |
* Sets the current velocity of this stuntdouble |
256 |
> |
* @param vel new velocity |
257 |
> |
*/ |
258 |
> |
void setVel(const Vector3d& vel) { |
259 |
> |
sd_->setVel(vel); |
260 |
> |
} |
261 |
> |
|
262 |
> |
/** |
263 |
> |
* Sets the velocity of this stuntdouble in specified snapshot |
264 |
> |
* @param vel velocity to be set |
265 |
> |
* @param snapshotNo |
266 |
> |
* @see #getVel |
267 |
> |
*/ |
268 |
> |
void setVel(const Vector3d& vel, int snapshotNo) { |
269 |
> |
sd_->setVel(vel, snapshotNo); |
270 |
> |
} |
271 |
> |
|
272 |
> |
/** |
273 |
> |
* Returns the previous rotation matrix of this stuntdouble |
274 |
> |
* @return the rotation matrix of this stuntdouble |
275 |
> |
*/ |
276 |
> |
RotMat3x3d getPrevA() { |
277 |
> |
return sd_->getPrevA(); |
278 |
> |
} |
279 |
> |
|
280 |
> |
/** |
281 |
> |
* Returns the current rotation matrix of this stuntdouble |
282 |
> |
* @return the rotation matrix of this stuntdouble |
283 |
> |
*/ |
284 |
> |
RotMat3x3d getA() { |
285 |
> |
return sd_->getA(); |
286 |
> |
} |
287 |
> |
|
288 |
> |
/** |
289 |
> |
* Returns the rotation matrix of this stuntdouble in specified snapshot |
290 |
> |
* |
291 |
> |
* @return the rotation matrix of this stuntdouble |
292 |
> |
* @param snapshotNo |
293 |
> |
*/ |
294 |
> |
RotMat3x3d getA(int snapshotNo) { |
295 |
> |
return sd_->getA(snapshotNo); |
296 |
> |
} |
297 |
> |
|
298 |
> |
/** |
299 |
> |
* Sets the previous rotation matrix of this stuntdouble |
300 |
> |
* @param a new rotation matrix |
301 |
> |
* @see #getA |
302 |
> |
*/ |
303 |
> |
void setPrevA(const RotMat3x3d& a) { |
304 |
> |
sd_->setPrevA(a); |
305 |
> |
} |
306 |
> |
|
307 |
> |
/** |
308 |
> |
* Sets the current rotation matrix of this stuntdouble |
309 |
> |
* @param a new rotation matrix |
310 |
> |
*/ |
311 |
> |
void setA(const RotMat3x3d& a) { |
312 |
> |
sd_->setA(a); |
313 |
> |
} |
314 |
> |
|
315 |
> |
/** |
316 |
> |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
317 |
> |
* @param a rotation matrix to be set |
318 |
> |
* @param snapshotNo |
319 |
> |
* @see #getA |
320 |
> |
*/ |
321 |
> |
void setA(const RotMat3x3d& a, int snapshotNo) { |
322 |
> |
sd_->setA(a, snapshotNo); |
323 |
> |
} |
324 |
> |
|
325 |
> |
/** |
326 |
> |
* Returns the previous angular momentum of this stuntdouble (body-fixed). |
327 |
> |
* @return the angular momentum of this stuntdouble |
328 |
> |
*/ |
329 |
> |
Vector3d getPrevJ() { |
330 |
> |
return sd_->getPrevJ(); |
331 |
> |
} |
332 |
> |
|
333 |
> |
/** |
334 |
> |
* Returns the current angular momentum of this stuntdouble (body -fixed). |
335 |
> |
* @return the angular momentum of this stuntdouble |
336 |
> |
*/ |
337 |
> |
Vector3d getJ() { |
338 |
> |
return sd_->getJ(); |
339 |
> |
} |
340 |
> |
|
341 |
> |
/** |
342 |
> |
* Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed). |
343 |
> |
* @return the angular momentum of this stuntdouble |
344 |
> |
* @param snapshotNo |
345 |
> |
*/ |
346 |
> |
Vector3d getJ(int snapshotNo) { |
347 |
> |
return sd_->getJ(snapshotNo); |
348 |
> |
} |
349 |
> |
|
350 |
> |
/** |
351 |
> |
* Sets the previous angular momentum of this stuntdouble (body-fixed). |
352 |
> |
* @param angMom new angular momentum |
353 |
> |
* @see #getJ |
354 |
> |
*/ |
355 |
> |
void setPrevJ(const Vector3d& angMom) { |
356 |
> |
sd_->setPrevJ(angMom); |
357 |
> |
} |
358 |
> |
|
359 |
> |
/** |
360 |
> |
* Sets the current angular momentum of this stuntdouble (body-fixed). |
361 |
> |
* @param angMom new angular momentum |
362 |
> |
*/ |
363 |
> |
void setJ(const Vector3d& angMom) { |
364 |
> |
sd_->setJ(angMom); |
365 |
> |
} |
366 |
> |
|
367 |
> |
/** |
368 |
> |
* Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed). |
369 |
> |
* @param angMom angular momentum to be set |
370 |
> |
* @param snapshotNo |
371 |
> |
* @see #getJ |
372 |
> |
*/ |
373 |
> |
void setJ(const Vector3d& angMom, int snapshotNo) { |
374 |
> |
sd_->setJ(angMom, snapshotNo); |
375 |
> |
} |
376 |
> |
|
377 |
> |
/** |
378 |
> |
* Returns the previous quaternion of this stuntdouble |
379 |
> |
* @return the quaternion of this stuntdouble |
380 |
> |
*/ |
381 |
> |
Quat4d getPrevQ() { |
382 |
> |
return sd_->getPrevQ(); |
383 |
> |
} |
384 |
> |
|
385 |
> |
/** |
386 |
> |
* Returns the current quaternion of this stuntdouble |
387 |
> |
* @return the quaternion of this stuntdouble |
388 |
> |
*/ |
389 |
> |
Quat4d getQ() { |
390 |
> |
return sd_->getQ(); |
391 |
> |
} |
392 |
> |
|
393 |
> |
/** |
394 |
> |
* Returns the quaternion of this stuntdouble in specified snapshot |
395 |
> |
* @return the quaternion of this stuntdouble |
396 |
> |
* @param snapshotNo |
397 |
> |
*/ |
398 |
> |
Quat4d getQ(int snapshotNo) { |
399 |
> |
return sd_->getQ(snapshotNo); |
400 |
> |
} |
401 |
> |
|
402 |
> |
/** |
403 |
> |
* Sets the previous quaternion of this stuntdouble |
404 |
> |
* @param q new quaternion |
405 |
> |
* @note actual storage data is rotation matrix |
406 |
> |
*/ |
407 |
> |
void setPrevQ(const Quat4d& q) { |
408 |
> |
sd_->setPrevQ(q); |
409 |
> |
} |
410 |
> |
|
411 |
> |
/** |
412 |
> |
* Sets the current quaternion of this stuntdouble |
413 |
> |
* @param q new quaternion |
414 |
> |
* @note actual storage data is rotation matrix |
415 |
> |
*/ |
416 |
> |
void setQ(const Quat4d& q) { |
417 |
> |
sd_->setQ(q); |
418 |
> |
} |
419 |
> |
|
420 |
> |
/** |
421 |
> |
* Sets the quaternion of this stuntdouble in specified snapshot |
422 |
> |
* |
423 |
> |
* @param q quaternion to be set |
424 |
> |
* @param snapshotNo |
425 |
> |
* @note actual storage data is rotation matrix |
426 |
> |
*/ |
427 |
> |
void setQ(const Quat4d& q, int snapshotNo) { |
428 |
> |
sd_->setQ(q, snapshotNo); |
429 |
> |
} |
430 |
> |
|
431 |
> |
/** |
432 |
> |
* Returns the previous euler angles of this stuntdouble |
433 |
> |
* @return the euler angles of this stuntdouble |
434 |
> |
*/ |
435 |
> |
Vector3d getPrevEuler() { |
436 |
> |
return sd_->getPrevEuler(); |
437 |
> |
} |
438 |
> |
|
439 |
> |
/** |
440 |
> |
* Returns the current euler angles of this stuntdouble |
441 |
> |
* @return the euler angles of this stuntdouble |
442 |
> |
*/ |
443 |
> |
Vector3d getEuler() { |
444 |
> |
return sd_->getEuler(); |
445 |
> |
} |
446 |
> |
|
447 |
> |
/** |
448 |
> |
* Returns the euler angles of this stuntdouble in specified snapshot. |
449 |
> |
* @return the euler angles of this stuntdouble |
450 |
> |
* @param snapshotNo |
451 |
> |
*/ |
452 |
> |
Vector3d getEuler(int snapshotNo) { |
453 |
> |
return sd_->getEuler(snapshotNo); |
454 |
> |
} |
455 |
> |
|
456 |
> |
/** |
457 |
> |
* Sets the previous euler angles of this stuntRealType. |
458 |
> |
* @param euler new euler angles |
459 |
> |
* @see #getEuler |
460 |
> |
* @note actual storage data is rotation matrix |
461 |
> |
*/ |
462 |
> |
void setPrevEuler(const Vector3d& euler) { |
463 |
> |
sd_->setPrevEuler(euler); |
464 |
> |
} |
465 |
> |
|
466 |
> |
/** |
467 |
> |
* Sets the current euler angles of this stuntdouble |
468 |
> |
* @param euler new euler angles |
469 |
> |
*/ |
470 |
> |
void setEuler(const Vector3d& euler) { |
471 |
> |
sd_->setEuler(euler); |
472 |
> |
} |
473 |
> |
|
474 |
> |
/** |
475 |
> |
* Sets the euler angles of this stuntdouble in specified snapshot |
476 |
> |
* |
477 |
> |
* @param euler euler angles to be set |
478 |
> |
* @param snapshotNo |
479 |
> |
* @note actual storage data is rotation matrix |
480 |
> |
*/ |
481 |
> |
void setEuler(const Vector3d& euler, int snapshotNo) { |
482 |
> |
sd_->setEuler(euler, snapshotNo); |
483 |
> |
} |
484 |
> |
|
485 |
> |
/** |
486 |
> |
* Returns the previous unit vectors of this stuntdouble |
487 |
> |
* @return the unit vectors of this stuntdouble |
488 |
> |
*/ |
489 |
> |
RotMat3x3d getPrevElectroFrame() { |
490 |
> |
return sd_->getPrevElectroFrame(); |
491 |
> |
} |
492 |
> |
|
493 |
> |
/** |
494 |
> |
* Returns the current unit vectors of this stuntdouble |
495 |
> |
* @return the unit vectors of this stuntdouble |
496 |
> |
*/ |
497 |
> |
RotMat3x3d getElectroFrame() { |
498 |
> |
return sd_->getElectroFrame(); |
499 |
> |
} |
500 |
> |
|
501 |
> |
/** |
502 |
> |
* Returns the unit vectors of this stuntdouble in specified snapshot |
503 |
> |
* |
504 |
> |
* @return the unit vectors of this stuntdouble |
505 |
> |
* @param snapshotNo |
506 |
> |
*/ |
507 |
> |
RotMat3x3d getElectroFrame(int snapshotNo) { |
508 |
> |
return sd_->getElectroFrame(snapshotNo); |
509 |
> |
} |
510 |
> |
|
511 |
> |
/** |
512 |
> |
* Returns the previous force of this stuntdouble |
513 |
> |
* @return the force of this stuntdouble |
514 |
> |
*/ |
515 |
> |
Vector3d getPrevFrc() { |
516 |
> |
return sd_->getPrevFrc(); |
517 |
> |
} |
518 |
> |
|
519 |
> |
/** |
520 |
> |
* Returns the current force of this stuntdouble |
521 |
> |
* @return the force of this stuntdouble |
522 |
> |
*/ |
523 |
> |
Vector3d getFrc() { |
524 |
> |
return sd_->getFrc(); |
525 |
> |
} |
526 |
> |
|
527 |
> |
/** |
528 |
> |
* Returns the force of this stuntdouble in specified snapshot |
529 |
> |
* |
530 |
> |
* @return the force of this stuntdouble |
531 |
> |
* @param snapshotNo |
532 |
> |
*/ |
533 |
> |
Vector3d getFrc(int snapshotNo) { |
534 |
> |
return sd_->getFrc(snapshotNo); |
535 |
> |
} |
536 |
> |
|
537 |
> |
/** |
538 |
> |
* Sets the previous force of this stuntdouble |
539 |
> |
* |
540 |
> |
* @param frc new force |
541 |
> |
* @see #getFrc |
542 |
> |
*/ |
543 |
> |
void setPrevFrc(const Vector3d& frc) { |
544 |
> |
sd_->setPrevFrc(frc); |
545 |
> |
} |
546 |
> |
|
547 |
> |
/** |
548 |
> |
* Sets the current force of this stuntdouble |
549 |
> |
* @param frc new force |
550 |
> |
*/ |
551 |
> |
void setFrc(const Vector3d& frc) { |
552 |
> |
sd_->setFrc(frc); |
553 |
> |
} |
554 |
> |
|
555 |
> |
/** |
556 |
> |
* Sets the force of this stuntdouble in specified snapshot |
557 |
> |
* |
558 |
> |
* @param frc force to be set |
559 |
> |
* @param snapshotNo |
560 |
> |
* @see #getFrc |
561 |
> |
*/ |
562 |
> |
void setFrc(const Vector3d& frc, int snapshotNo) { |
563 |
> |
sd_->setFrc(frc, snapshotNo); |
564 |
> |
} |
565 |
> |
|
566 |
> |
/** |
567 |
> |
* Adds force into the previous force of this stuntdouble |
568 |
> |
* |
569 |
> |
* @param frc new force |
570 |
> |
* @see #getFrc |
571 |
> |
*/ |
572 |
> |
void addPrevFrc(const Vector3d& frc) { |
573 |
> |
sd_->addPrevFrc(frc); |
574 |
> |
} |
575 |
> |
|
576 |
> |
/** |
577 |
> |
* Adds force into the current force of this stuntdouble |
578 |
> |
* @param frc new force |
579 |
> |
*/ |
580 |
> |
void addFrc(const Vector3d& frc) { |
581 |
> |
sd_->addFrc(frc); |
582 |
> |
} |
583 |
> |
|
584 |
> |
/** |
585 |
> |
* Adds force into the force of this stuntdouble in specified snapshot |
586 |
> |
* |
587 |
> |
* @param frc force to be set |
588 |
> |
* @param snapshotNo |
589 |
> |
* @see #getFrc |
590 |
> |
*/ |
591 |
> |
void addFrc(const Vector3d& frc, int snapshotNo) { |
592 |
> |
sd_->addFrc(frc, snapshotNo); |
593 |
> |
} |
594 |
> |
|
595 |
> |
/** |
596 |
> |
* Returns the previous torque of this stuntdouble |
597 |
> |
* @return the torque of this stuntdouble |
598 |
> |
*/ |
599 |
> |
Vector3d getPrevTrq() { |
600 |
> |
return sd_->getPrevTrq(); |
601 |
> |
} |
602 |
> |
|
603 |
> |
/** |
604 |
> |
* Returns the current torque of this stuntdouble |
605 |
> |
* @return the torque of this stuntdouble |
606 |
> |
*/ |
607 |
> |
Vector3d getTrq() { |
608 |
> |
return sd_->getTrq(); |
609 |
> |
} |
610 |
> |
|
611 |
> |
/** |
612 |
> |
* Returns the torque of this stuntdouble in specified snapshot |
613 |
> |
* |
614 |
> |
* @return the torque of this stuntdouble |
615 |
> |
* @param snapshotNo |
616 |
> |
*/ |
617 |
> |
Vector3d getTrq(int snapshotNo) { |
618 |
> |
return sd_->getTrq(snapshotNo); |
619 |
> |
} |
620 |
> |
|
621 |
> |
/** |
622 |
> |
* Sets the previous torque of this stuntdouble |
623 |
> |
* |
624 |
> |
* @param trq new torque |
625 |
> |
* @see #getTrq |
626 |
> |
*/ |
627 |
> |
void setPrevTrq(const Vector3d& trq) { |
628 |
> |
sd_->setPrevTrq(trq); |
629 |
> |
} |
630 |
> |
|
631 |
> |
/** |
632 |
> |
* Sets the current torque of this stuntdouble |
633 |
> |
* @param trq new torque |
634 |
> |
*/ |
635 |
> |
void setTrq(const Vector3d& trq) { |
636 |
> |
sd_->setTrq(trq); |
637 |
> |
} |
638 |
> |
|
639 |
> |
/** |
640 |
> |
* Sets the torque of this stuntdouble in specified snapshot |
641 |
> |
* |
642 |
> |
* @param trq torque to be set |
643 |
> |
* @param snapshotNo |
644 |
> |
* @see #getTrq |
645 |
> |
*/ |
646 |
> |
void setTrq(const Vector3d& trq, int snapshotNo) { |
647 |
> |
sd_->setTrq(trq, snapshotNo); |
648 |
> |
} |
649 |
> |
|
650 |
> |
/** |
651 |
> |
* Adds torque into the previous torque of this stuntdouble |
652 |
> |
* |
653 |
> |
* @param trq new torque |
654 |
> |
* @see #getTrq |
655 |
> |
*/ |
656 |
> |
void addPrevTrq(const Vector3d& trq) { |
657 |
> |
sd_->addPrevTrq(trq); |
658 |
> |
} |
659 |
> |
|
660 |
> |
/** |
661 |
> |
* Adds torque into the current torque of this stuntdouble |
662 |
> |
* @param trq new torque |
663 |
> |
*/ |
664 |
> |
void addTrq(const Vector3d& trq) { |
665 |
> |
sd_->addTrq(trq); |
666 |
> |
} |
667 |
> |
|
668 |
> |
/** |
669 |
> |
* Adds torque into the torque of this stuntdouble in specified snapshot |
670 |
> |
* |
671 |
> |
* @param trq torque to be add |
672 |
> |
* @param snapshotNo |
673 |
> |
* @see #getTrq |
674 |
> |
*/ |
675 |
> |
void addTrq(const Vector3d& trq, int snapshotNo) { |
676 |
> |
sd_->addTrq(trq, snapshotNo); |
677 |
> |
} |
678 |
> |
|
679 |
> |
/** Set the force of this stuntdouble to zero */ |
680 |
> |
void zeroForcesAndTorques() { |
681 |
> |
sd_->zeroForcesAndTorques(); |
682 |
> |
} |
683 |
> |
/** |
684 |
> |
* Returns the inertia tensor of this stuntdouble |
685 |
> |
* @return the inertia tensor of this stuntdouble |
686 |
> |
*/ |
687 |
> |
Mat3x3d getI() { |
688 |
> |
return sd_->getI(); |
689 |
> |
} |
690 |
> |
|
691 |
> |
/** |
692 |
> |
* Returns the gradient of this stuntdouble |
693 |
> |
* @return the gradient of this stuntdouble |
694 |
> |
*/ |
695 |
> |
std::vector<RealType> getGrad() { |
696 |
> |
return sd_->getGrad(); |
697 |
> |
} |
698 |
> |
|
699 |
> |
/** |
700 |
> |
* Tests the if this stuntdouble is a linear rigidbody |
701 |
> |
* |
702 |
> |
* @return true if this stuntdouble is a linear rigidbody, otherwise return false |
703 |
> |
* @note atom and directional atom will always return false |
704 |
> |
* |
705 |
> |
* @see #linearAxis |
706 |
> |
*/ |
707 |
> |
bool isLinear() { |
708 |
> |
return sd_->isLinear(); |
709 |
> |
} |
710 |
> |
|
711 |
> |
/** |
712 |
> |
* Returns the linear axis of the rigidbody, atom and directional atom will always return -1 |
713 |
> |
* |
714 |
> |
* @return the linear axis of the rigidbody |
715 |
> |
* |
716 |
> |
* @see #isLinear |
717 |
> |
*/ |
718 |
> |
int linearAxis() { |
719 |
> |
return sd_->linearAxis(); |
720 |
> |
} |
721 |
> |
|
722 |
> |
/** Returns the mass of this stuntdouble */ |
723 |
> |
RealType getMass() { |
724 |
> |
return sd_->getMass(); |
725 |
> |
} |
726 |
> |
|
727 |
> |
/** |
728 |
> |
* Sets the mass of this stuntdoulbe |
729 |
> |
* @param mass the mass to be set |
730 |
> |
*/ |
731 |
> |
void setMass(RealType mass) { |
732 |
> |
sd_->setMass(mass); |
733 |
> |
} |
734 |
> |
|
735 |
> |
/** Returns the name of this stuntdouble */ |
736 |
> |
std::string getType() { |
737 |
> |
return sd_->getType(); |
738 |
> |
} |
739 |
> |
|
740 |
> |
/** Sets the name of this stuntRealType*/ |
741 |
> |
void setType(const std::string& name) { |
742 |
> |
sd_->setType(name); |
743 |
> |
} |
744 |
> |
|
745 |
> |
/** |
746 |
> |
* Converts a lab fixed vector to a body fixed vector. |
747 |
> |
* @return body fixed vector |
748 |
> |
* @param v lab fixed vector |
749 |
> |
*/ |
750 |
> |
Vector3d lab2Body(const Vector3d& v) { |
751 |
> |
return sd_->lab2Body(v); |
752 |
> |
} |
753 |
> |
|
754 |
> |
/** |
755 |
> |
* Converts a body fixed vector to a lab fixed vector. |
756 |
> |
* @return corresponding lab fixed vector |
757 |
> |
* @param v body fixed vector |
758 |
> |
*/ |
759 |
> |
Vector3d body2Lab(const Vector3d& v){ |
760 |
> |
return sd_->body2Lab(v); |
761 |
> |
} |
762 |
> |
/** |
763 |
> |
* <p> |
764 |
> |
* The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on |
765 |
> |
* the elements of a data structure. In this way, you can change the operation being performed |
766 |
> |
* on a structure without the need of changing the classes of the elements that you are operating |
767 |
> |
* on. Using a Visitor pattern allows you to decouple the classes for the data structure and the |
768 |
> |
* algorithms used upon them |
769 |
> |
* </p> |
770 |
> |
* @param v visitor |
771 |
> |
*/ |
772 |
> |
void accept(BaseVisitor* v) { |
773 |
> |
sd_->accept(v); |
774 |
> |
} |
775 |
> |
|
776 |
> |
//below functions are just forward functions |
777 |
> |
/** |
778 |
> |
* Adds property into property map |
779 |
> |
* @param genData GenericData to be added into PropertyMap |
780 |
> |
*/ |
781 |
> |
void addProperty(GenericData* genData){ |
782 |
> |
sd_->addProperty(genData); |
783 |
> |
} |
784 |
> |
|
785 |
> |
/** |
786 |
> |
* Removes property from PropertyMap by name |
787 |
> |
* @param propName the name of property to be removed |
788 |
> |
*/ |
789 |
> |
void removeProperty(const std::string& propName) { |
790 |
> |
sd_->removeProperty(propName); |
791 |
> |
} |
792 |
> |
|
793 |
> |
/** |
794 |
> |
* clear all of the properties |
795 |
> |
*/ |
796 |
> |
void clearProperties() { |
797 |
> |
sd_->clearProperties(); |
798 |
> |
} |
799 |
> |
|
800 |
> |
/** |
801 |
> |
* Returns all names of properties |
802 |
> |
* @return all names of properties |
803 |
> |
*/ |
804 |
> |
std::vector<std::string> getPropertyNames() { |
805 |
> |
return sd_->getPropertyNames(); |
806 |
> |
} |
807 |
> |
|
808 |
> |
/** |
809 |
> |
* Returns all of the properties in PropertyMap |
810 |
> |
* @return all of the properties in PropertyMap |
811 |
> |
*/ |
812 |
> |
std::vector<GenericData*> getProperties() { |
813 |
> |
return sd_->getProperties(); |
814 |
> |
} |
815 |
> |
|
816 |
> |
/** |
817 |
> |
* Returns property |
818 |
> |
* @param propName name of property |
819 |
> |
* @return a pointer point to property with propName. If no property named propName |
820 |
> |
* exists, return NULL |
821 |
> |
*/ |
822 |
> |
GenericData* getPropertyByName(const std::string& propName) { |
823 |
> |
return sd_->getPropertyByName(propName); |
824 |
> |
} |
825 |
> |
|
826 |
> |
private: |
827 |
> |
StuntDouble* sd_; |
828 |
> |
BoolGenericData* moved_; |
829 |
> |
BoolGenericData* moving_; |
830 |
> |
}; |
831 |
> |
|
832 |
|
} |
833 |
|
|
834 |
|
#endif |