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 1443 by tim, Fri Jul 30 14:44:10 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 15 | Line 16 | void MoLocator::placeMol( const Vector3d& offset, cons
16   }
17  
18   void MoLocator::placeMol( const Vector3d& offset, const Vector3d& ort, Molecule* mol){
19 <  Vector3d newCoor;
20 <  Vector3d velocity(0.0, 0.0, 0.0);
21 <  Vector3d angMomentum(0.0, 0.0, 0.0);
21 <  double quaternion[4];
19 >  double newCoor[3];
20 >  double curRefCoor[3];
21 >  double zeroVector[3];
22    vector<StuntDouble*> myIntegrableObjects;
23 <
24 <  quaternion[0] = 1.0;
25 <  quaternion[1] = 0.0;
26 <  quaternion[2] = 0.0;
27 <  quaternion[3] = 0.0;
28 <
23 >  double rotMat[3][3];
24 >  
25 >  zeroVector[0] = 0.0;
26 >  zeroVector[1] = 0.0;
27 >  zeroVector[2] = 0.0;
28 >  
29 >  latVec2RotMat(ort, rotMat);
30 >  
31    myIntegrableObjects = mol->getIntegrableObjects();
32  
33    if(myIntegrableObjects.size() != nIntegrableObjects){
# Line 39 | Line 41 | void MoLocator::placeMol( const Vector3d& offset, cons
41      
42    for(int i=0; i<nIntegrableObjects; i++) {
43  
44 <      newCoor = refCoords[i] + offset;
45 <      myIntegrableObjects[i]->setPos( newCoor.vec);
46 <      myIntegrableObjects[i]->setVel(velocity.vec);
44 >    //calculate the reference coordinate for integrable objects after rotation
45 >    curRefCoor[0] = refCoords[i][0];
46 >    curRefCoor[1] = refCoords[i][1];
47 >    curRefCoor[2] = refCoords[i][2];
48 >    
49 >    matVecMul3(rotMat, curRefCoor, newCoor);    
50  
51 <      if(myIntegrableObjects[i]->isDirectional()){
52 <        myIntegrableObjects[i]->setQ(quaternion);
53 <        myIntegrableObjects[i]->setJ(angMomentum.vec);  
54 <      }
51 >    newCoor[0] +=  offset[0];
52 >    newCoor[1] +=  offset[1];
53 >    newCoor[2] +=  offset[2];
54 >
55 >    myIntegrableObjects[i]->setPos( newCoor);
56 >    myIntegrableObjects[i]->setVel(zeroVector);
57 >
58 >    if(myIntegrableObjects[i]->isDirectional()){
59 >      myIntegrableObjects[i]->setA(rotMat);
60 >      myIntegrableObjects[i]->setJ(zeroVector);  
61 >    }
62    }
63  
64   }
# Line 63 | Line 75 | void MoLocator::calcRefCoords( void ){
75    double currAtomMass;
76    double molMass;
77    
66  mass.resize(nIntegrableObjects);
67  
78    nAtoms= myStamp->getNAtoms();
79    nRigidBodies = myStamp->getNRigidBodies();
80  
# Line 140 | Line 150 | void MoLocator::calcRefCoords( void ){
150      refCoords[i] -= refMolCom;
151   }
152  
153 +
154 + void latVec2RotMat(const Vector3d& lv, double rotMat[3][3]){
155 +
156 +  double theta, phi, psi;
157 +  
158 +  theta =acos(lv.z);
159 +  phi = atan2(lv.y, lv.x);
160 +  psi = 0;
161 +
162 +  rotMat[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi));
163 +  rotMat[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi));
164 +  rotMat[0][2] = sin(theta) * sin(psi);
165 +  
166 +  rotMat[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi));
167 +  rotMat[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi));
168 +  rotMat[1][2] = sin(theta) * cos(psi);
169 +  
170 +  rotMat[2][0] = sin(phi) * sin(theta);
171 +  rotMat[2][1] = -cos(phi) * sin(theta);
172 +  rotMat[2][2] = cos(theta);
173 + }
174 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines