ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/RigidBody.hpp
Revision: 1452
Committed: Mon Aug 23 15:11:36 2004 UTC (19 years, 10 months ago) by tim
File size: 3316 byte(s)
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 gezelter 1100 #ifndef __RIGIDBODY_HPP__
2     #define __RIGIDBODY_HPP__
3    
4     #include <vector>
5     //#include "Atom.hpp"
6     //#include "AtomStamp.hpp"
7     #include "RigidBodyStamp.hpp"
8     #include "StuntDouble.hpp"
9     using namespace std;
10    
11     class Atom;
12     class AtomStamp;
13    
14     typedef struct {
15     double vec[3];
16     double& operator[](int index) {return vec[index];}
17     } vec3;
18    
19     typedef struct {
20     double mat[3][3];
21     double* operator[](int index) {return mat[index];}
22     } mat3x3;
23    
24     class RigidBody : public StuntDouble {
25    
26     public:
27    
28     RigidBody();
29 tim 1234 //RigidBody(const RigidBody& rb);
30    
31 gezelter 1100 virtual ~RigidBody();
32    
33     void addAtom(Atom* at, AtomStamp* ats);
34    
35     void getPos( double theP[3] );
36     void setPos( double theP[3] );
37    
38     void getVel( double theV[3] );
39     void setVel( double theV[3] );
40    
41     void getFrc( double theF[3] );
42 tim 1452 void setFrc(double theF[3] );
43 gezelter 1100 void addFrc( double theF[3] );
44     void zeroForces();
45 tim 1118
46     virtual bool isLinear() {return is_linear;}
47     virtual int linearAxis() {return linear_axis;}
48 gezelter 1100
49     double getMass( void ) { return mass; }
50    
51     void printAmatIndex( void );
52 tim 1113 void setEuler( double phi, double theta, double psi );
53 gezelter 1100 void getQ( double the_q[4] ); // get the quanternions
54     void setQ( double the_q[4] );
55    
56     void getA( double the_A[3][3] ); // get the full rotation matrix
57     void setA( double the_A[3][3] );
58    
59     void getJ( double theJ[3] );
60     void setJ( double theJ[3] );
61    
62 tim 1108 virtual void setType(char* type) {strcpy(rbName, type);}
63     virtual char* getType() { return rbName;}
64    
65 gezelter 1100 void getTrq( double theT[3] );
66 tim 1452 void setTrq(double theT[3]);
67 gezelter 1100 void addTrq( double theT[3] );
68    
69     void getI( double the_I[3][3] );
70     void lab2Body( double r[3] );
71     void body2Lab( double r[3] );
72    
73 chrisfen 1187 double getZangle( );
74     void setZangle( double zAng );
75     void addZangle( double zAng );
76    
77 gezelter 1100 void calcRefCoords( void );
78     void doEulerToRotMat(vec3 &euler, mat3x3 &myA );
79     void calcForcesAndTorques( void );
80     void updateAtoms( void );
81    
82     //void yourAtomsHaveMoved( void );
83    
84     // Four functions added for derivatives with respect to Euler Angles:
85     // (Needed for minimization routines):
86    
87     void getGrad(double gradient[6] );
88     void getEulerAngles( double myEuler[3] );
89    
90     double max(double x, double y);
91     double min(double x, double y);
92    
93    
94     // utility routines
95    
96     void findCOM( void );
97 tim 1118
98     virtual void accept(BaseVisitor* v);
99    
100     vector<Atom*> getAtoms() { return myAtoms;}
101 tim 1234 int getNumAtoms() {return myAtoms.size();}
102    
103     void getAtomPos(double theP[3], int index);
104 tim 1284 void getAtomVel(double theV[3], int index);
105 tim 1254 void getAtomRefCoor(double pos[3], int index);
106 gezelter 1100 protected:
107    
108     double mass; // the total mass
109     double pos[3]; // the position array (center of mass)
110     double vel[3]; // the velocity array (center of mass)
111     double frc[3]; // the force array (center of mass)
112     double trq[3]; // the torque vector ( space fixed )
113     double ji[3]; // the angular momentum vector (body fixed)
114     double A[3][3]; // the rotation matrix
115     double I[3][3]; // the inertial tensor (body fixed)
116     double sU[3][3]; // the standard unit vectors (body fixed)
117 chrisfen 1187 double zAngle; // the rotation about the z-axis (body fixed)
118 gezelter 1100
119 tim 1118 bool is_linear;
120     int linear_axis;
121 gezelter 1174 double momIntTol;
122 tim 1118
123 gezelter 1100 vector<Atom*> myAtoms; // the vector of atoms
124     vector<vec3> refCoords;
125     vector<mat3x3> refOrients;
126    
127 tim 1108 char rbName[100]; //it will eventually be converted into string
128 gezelter 1100 };
129    
130     #endif