ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/StuntDouble.hpp
Revision: 2272
Committed: Wed Aug 10 19:17:39 2005 UTC (18 years, 11 months ago) by gezelter
File size: 28569 byte(s)
Log Message:
putting spaceballs back where they belong

File Contents

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

Properties

Name Value
svn:executable *