| 1 |
#ifndef __RIGIDBODY_HPP__ |
| 2 |
#define __RIGIDBODY_HPP__ |
| 3 |
|
| 4 |
#include <vector> |
| 5 |
using namespace std; |
| 6 |
|
| 7 |
class VDWAtom; |
| 8 |
|
| 9 |
typedef struct { |
| 10 |
double vec[3]; |
| 11 |
double& operator[](int index) {return vec[index];} |
| 12 |
} vec3; |
| 13 |
|
| 14 |
typedef struct { |
| 15 |
double mat[3][3]; |
| 16 |
double* operator[](int index) {return mat[index];} |
| 17 |
} mat3x3; |
| 18 |
|
| 19 |
class RigidBody { |
| 20 |
|
| 21 |
public: |
| 22 |
|
| 23 |
RigidBody(); |
| 24 |
virtual ~RigidBody(); |
| 25 |
|
| 26 |
void addAtom(VDWAtom* at); |
| 27 |
|
| 28 |
void getPos( double theP[3] ); |
| 29 |
void setPos( double theP[3] ); |
| 30 |
|
| 31 |
virtual bool isLinear() {return is_linear;} |
| 32 |
virtual int linearAxis() {return linear_axis;} |
| 33 |
|
| 34 |
double getMass( void ) { return mass; } |
| 35 |
|
| 36 |
void setEuler( double phi, double theta, double psi ); |
| 37 |
void getQ( double the_q[4] ); // get the quanternions |
| 38 |
void setQ( double the_q[4] ); |
| 39 |
|
| 40 |
void getA( double the_A[3][3] ); // get the full rotation matrix |
| 41 |
void setA( double the_A[3][3] ); |
| 42 |
|
| 43 |
void getI( double the_I[3][3] ); |
| 44 |
void lab2Body( double r[3] ); |
| 45 |
void body2Lab( double r[3] ); |
| 46 |
|
| 47 |
void calcRefCoords( void ); |
| 48 |
void doEulerToRotMat(double euler[3], double myA[3][3] ); |
| 49 |
void updateAtoms( void ); |
| 50 |
|
| 51 |
void getGrad(double gradient[6] ); |
| 52 |
void getEulerAngles( double myEuler[3] ); |
| 53 |
|
| 54 |
double max(double x, double y); |
| 55 |
double min(double x, double y); |
| 56 |
|
| 57 |
double findMaxExtent( void ); |
| 58 |
|
| 59 |
// utility routines |
| 60 |
|
| 61 |
void findCOM( void ); |
| 62 |
|
| 63 |
vector<VDWAtom*> getAtoms() { return myAtoms;} |
| 64 |
int getNumAtoms() {return myAtoms.size();} |
| 65 |
|
| 66 |
void getAtomPos(double theP[3], int index); |
| 67 |
void getAtomRefCoor(double pos[3], int index); |
| 68 |
double getAtomRpar(int index); |
| 69 |
double getAtomEps(int index); |
| 70 |
char *getAtomBase(int index); |
| 71 |
|
| 72 |
protected: |
| 73 |
|
| 74 |
double mass; // the total mass |
| 75 |
double pos[3]; // the position array (center of mass) |
| 76 |
double A[3][3]; // the rotation matrix |
| 77 |
double I[3][3]; // the inertial tensor (body fixed) |
| 78 |
double sU[3][3]; // the standard unit vectors (body fixed) |
| 79 |
|
| 80 |
bool is_linear; |
| 81 |
int linear_axis; |
| 82 |
double momIntTol; |
| 83 |
|
| 84 |
vector<VDWAtom*> myAtoms; // the vector of atoms |
| 85 |
vector<vec3> refCoords; |
| 86 |
vector<mat3x3> refOrients; |
| 87 |
|
| 88 |
char rbName[100]; //it will eventually be converted into string |
| 89 |
}; |
| 90 |
|
| 91 |
#endif |