ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/RigidBody.hpp
Revision: 1108
Committed: Wed Apr 14 15:37:41 2004 UTC (20 years, 2 months ago) by tim
File size: 2744 byte(s)
Log Message:
Change DumpWriter and InitFromFile

File Contents

# Content
1 #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 virtual ~RigidBody();
30
31 void addAtom(Atom* at, AtomStamp* ats);
32
33 void getPos( double theP[3] );
34 void setPos( double theP[3] );
35
36 void getVel( double theV[3] );
37 void setVel( double theV[3] );
38
39 void getFrc( double theF[3] );
40 void addFrc( double theF[3] );
41 void zeroForces();
42
43 double getMass( void ) { return mass; }
44
45 void printAmatIndex( void );
46 void setEulerAngles( double phi, double theta, double psi );
47 void getQ( double the_q[4] ); // get the quanternions
48 void setQ( double the_q[4] );
49
50 void getA( double the_A[3][3] ); // get the full rotation matrix
51 void setA( double the_A[3][3] );
52
53 void getJ( double theJ[3] );
54 void setJ( double theJ[3] );
55
56 virtual void setType(char* type) {strcpy(rbName, type);}
57 virtual char* getType() { return rbName;}
58
59 void getTrq( double theT[3] );
60 void addTrq( double theT[3] );
61
62 void getI( double the_I[3][3] );
63 void lab2Body( double r[3] );
64 void body2Lab( double r[3] );
65
66 void calcRefCoords( void );
67 void doEulerToRotMat(vec3 &euler, mat3x3 &myA );
68 void calcForcesAndTorques( void );
69 void updateAtoms( void );
70
71 //void yourAtomsHaveMoved( void );
72
73 // Four functions added for derivatives with respect to Euler Angles:
74 // (Needed for minimization routines):
75
76 void getGrad(double gradient[6] );
77 void getEulerAngles( double myEuler[3] );
78
79 double max(double x, double y);
80 double min(double x, double y);
81
82
83 // utility routines
84
85 void findCOM( void );
86 void findOrient( void );
87
88 protected:
89
90 double mass; // the total mass
91 double pos[3]; // the position array (center of mass)
92 double vel[3]; // the velocity array (center of mass)
93 double frc[3]; // the force array (center of mass)
94 double trq[3]; // the torque vector ( space fixed )
95 double ji[3]; // the angular momentum vector (body fixed)
96 double A[3][3]; // the rotation matrix
97 double I[3][3]; // the inertial tensor (body fixed)
98 double sU[3][3]; // the standard unit vectors (body fixed)
99
100 vector<Atom*> myAtoms; // the vector of atoms
101 vector<vec3> refCoords;
102 vector<mat3x3> refOrients;
103
104 bool com_good;
105 bool forces_good;
106 bool precalc_done;
107 bool orient_good;
108
109 char rbName[100]; //it will eventually be converted into string
110 };
111
112 #endif