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 1432 by tim, Thu Jul 29 03:31:50 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 63 | Line 70 | void MoLocator::calcRefCoords( void ){
70    double currAtomMass;
71    double molMass;
72    
66  mass.resize(nIntegrableObjects);
67  
73    nAtoms= myStamp->getNAtoms();
74    nRigidBodies = myStamp->getNRigidBodies();
75  
# Line 140 | 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