ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-1.0/utils/sysbuilder/MoLocator.cpp
(Generate patch)

Comparing trunk/OOPSE-1.0/utils/sysbuilder/MoLocator.cpp (file contents):
Revision 1429 by tim, Wed Jul 28 20:29:49 2004 UTC vs.
Revision 1435 by tim, Thu Jul 29 18:16:16 2004 UTC

# Line 5 | Line 5
5  
6   #include "simError.h"
7   #include "MoLocator.hpp"
8 + #include "MatVec3.h"
9  
10   MoLocator::MoLocator( MoleculeStamp* theStamp, ForceFields* theFF){
11  
# Line 20 | Line 21 | void MoLocator::placeMol( const Vector3d& offset, cons
21    Vector3d angMomentum(0.0, 0.0, 0.0);
22    double quaternion[4];
23    vector<StuntDouble*> myIntegrableObjects;
24 <
24 >  double rotMat[3][3];
25 >  
26    quaternion[0] = 1.0;
27    quaternion[1] = 0.0;
28    quaternion[2] = 0.0;
29    quaternion[3] = 0.0;
30  
31 +  latVec2RotMat(ort, rotMat);
32 +  
33    myIntegrableObjects = mol->getIntegrableObjects();
34  
35    if(myIntegrableObjects.size() != nIntegrableObjects){
# Line 39 | Line 43 | void MoLocator::placeMol( const Vector3d& offset, cons
43      
44    for(int i=0; i<nIntegrableObjects; i++) {
45  
46 <      newCoor = refCoords[i] + offset;
47 <      myIntegrableObjects[i]->setPos( newCoor.vec);
48 <      myIntegrableObjects[i]->setVel(velocity.vec);
46 >    //calculate the reference coordinate for integrable objects after rotation
47 >    matVecMul3(rotMat, refCoords[i].vec, newCoor.vec);    
48 >    newCoor +=  offset;
49  
50 <      if(myIntegrableObjects[i]->isDirectional()){
51 <        myIntegrableObjects[i]->setQ(quaternion);
52 <        myIntegrableObjects[i]->setJ(angMomentum.vec);  
53 <      }
50 >    myIntegrableObjects[i]->setPos( newCoor.vec);
51 >    myIntegrableObjects[i]->setVel(velocity.vec);
52 >
53 >    if(myIntegrableObjects[i]->isDirectional()){
54 >      myIntegrableObjects[i]->setA(rotMat);
55 >      myIntegrableObjects[i]->setJ(angMomentum.vec);  
56 >    }
57    }
58  
59   }
# Line 61 | Line 68 | void MoLocator::calcRefCoords( void ){
68    int nAtomsInRb;
69    double totMassInRb;
70    double currAtomMass;
71 <
65 <  double totMass;
71 >  double molMass;
72    
67  mass.resize(nIntegrableObjects);
68  
73    nAtoms= myStamp->getNAtoms();
74    nRigidBodies = myStamp->getNRigidBodies();
75  
72  //
76    for(size_t i=0; i<nAtoms; i++){
77  
78      currAtomStamp = myStamp->getAtom(i);
# Line 122 | Line 125 | void MoLocator::calcRefCoords( void ){
125      refCoords.push_back(coor);
126    }
127  
128 +
129    //calculate the reference center of mass
130 +  molMass = 0;
131 +  refMolCom.x = 0;
132 +  refMolCom.y = 0;
133 +  refMolCom.z = 0;
134 +  
135    for(int i = 0; i < nIntegrableObjects; i++){
136      refMolCom += refCoords[i] * mass[i];
137 <    totMass += mass[i];
137 >   molMass += mass[i];
138    }
139    
140 <  refMolCom /= totMass;
140 >  refMolCom /= molMass;
141  
142    //move the reference center of mass to (0,0,0) and adjust the reference coordinate
143    //of the integrabel objects
# Line 136 | Line 145 | void MoLocator::calcRefCoords( void ){
145      refCoords[i] -= refMolCom;
146   }
147  
148 +
149 + void latVec2RotMat(const Vector3d& lv, double rotMat[3][3]){
150 +
151 +  double theta, phi, psi;
152 +  
153 +  theta =acos(lv.z);
154 +  phi = atan2(lv.y, lv.x);
155 +  psi = 0;
156 +
157 +  rotMat[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi));
158 +  rotMat[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi));
159 +  rotMat[0][2] = sin(theta) * sin(psi);
160 +  
161 +  rotMat[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi));
162 +  rotMat[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi));
163 +  rotMat[1][2] = sin(theta) * cos(psi);
164 +  
165 +  rotMat[2][0] = sin(phi) * sin(theta);
166 +  rotMat[2][1] = -cos(phi) * sin(theta);
167 +  rotMat[2][2] = cos(theta);
168 + }
169 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines