| 1 |
mmeineke |
503 |
#include <cstdlib> |
| 2 |
|
|
#include <cmath> |
| 3 |
|
|
|
| 4 |
mmeineke |
501 |
#include "MoLocator.hpp" |
| 5 |
mmeineke |
503 |
|
| 6 |
|
|
|
| 7 |
|
|
MoLocator::MoLocator( MoleCuleStamp* theStamp ){ |
| 8 |
|
|
|
| 9 |
|
|
myStamp = theStamp; |
| 10 |
|
|
nAtoms = myStamp->getNAtoms(); |
| 11 |
|
|
|
| 12 |
|
|
myCoords = NULL; |
| 13 |
|
|
|
| 14 |
|
|
calcRefCoords(); |
| 15 |
|
|
} |
| 16 |
|
|
|
| 17 |
|
|
MoLocator::~MoLocator(){ |
| 18 |
|
|
|
| 19 |
|
|
if( myCoords != NULL ) delete[] myCoords; |
| 20 |
|
|
} |
| 21 |
|
|
|
| 22 |
|
|
void MoLocator::placeMol( double pos[3], double A[3][3], Atom** atomArray){ |
| 23 |
|
|
|
| 24 |
|
|
int i,j,k; |
| 25 |
|
|
double r[3]; |
| 26 |
|
|
|
| 27 |
|
|
AtomStamp* currAtom; |
| 28 |
|
|
DirectionalAtom* dAtom; |
| 29 |
|
|
|
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
void MoLocator::calcRefCoords( void ){ |
| 33 |
|
|
|
| 34 |
|
|
int i,j,k; |
| 35 |
|
|
AtomStamp* currAtom; |
| 36 |
|
|
double centerX, centerY, centerZ; |
| 37 |
|
|
double smallX, smallY, smallZ; |
| 38 |
|
|
double bigX, bigY, bigZ; |
| 39 |
|
|
double dx, dy, dz; |
| 40 |
|
|
double dsqr; |
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
centerX = 0.0; |
| 44 |
|
|
centerY = 0.0; |
| 45 |
|
|
centerZ = 0.0; |
| 46 |
|
|
for(i=0; <nAtoms; i++){ |
| 47 |
|
|
|
| 48 |
|
|
currAtom = myStamp->getAtom(i); |
| 49 |
|
|
|
| 50 |
|
|
centerX += currAtom->getPosX(); |
| 51 |
|
|
centerY += currAtom->getPosY(); |
| 52 |
|
|
centerZ += currAtom->getPosZ(); |
| 53 |
|
|
} |
| 54 |
|
|
|
| 55 |
|
|
centerX /= nAtoms; |
| 56 |
|
|
centerY /= nAtoms; |
| 57 |
|
|
centerZ /= nAtoms; |
| 58 |
|
|
|
| 59 |
|
|
myCoords = new double[nAtoms*3]; |
| 60 |
|
|
|
| 61 |
|
|
j = 0; |
| 62 |
|
|
for(i=0; <nAtoms; i++){ |
| 63 |
|
|
|
| 64 |
|
|
currAtom = myStamp->getAtom(i); |
| 65 |
|
|
j = i*3; |
| 66 |
|
|
|
| 67 |
|
|
myCoords[j] = currAtom->getPosX() - centerX; |
| 68 |
|
|
myCoords[j+1] = currAtom->getPosY() - centerY; |
| 69 |
|
|
myCoords[j+2] = currAtom->getPosZ() - centerZ; |
| 70 |
|
|
} |
| 71 |
|
|
|
| 72 |
|
|
smallX = myCoords[0]; |
| 73 |
|
|
smallY = myCoords[1]; |
| 74 |
|
|
smallZ = myCoords[2]; |
| 75 |
|
|
|
| 76 |
|
|
bigX = myCoords[0]; |
| 77 |
|
|
bigY = myCoords[1]; |
| 78 |
|
|
bigZ = myCoords[2]; |
| 79 |
|
|
|
| 80 |
|
|
j=0; |
| 81 |
|
|
for(i=1; i<nAtoms; i++){ |
| 82 |
|
|
j= i*3; |
| 83 |
|
|
|
| 84 |
|
|
if( myCoords[j] < smallX ) smallX = myCoords[j]; |
| 85 |
|
|
if( myCoords[j+1] < smallY ) smallY = myCoords[j+1]; |
| 86 |
|
|
if( myCoords[j+2] < smallZ ) smallZ = myCoords[j+2]; |
| 87 |
|
|
|
| 88 |
|
|
if( myCoords[j] > bigX ) bigX = myCoords[j]; |
| 89 |
|
|
if( myCoords[j+1] > bigY ) bigY = myCoords[j+1]; |
| 90 |
|
|
if( myCoords[j+2] > bigZ ) bigZ = myCoords[j+2]; |
| 91 |
|
|
} |
| 92 |
|
|
|
| 93 |
|
|
|
| 94 |
|
|
dx = bigX - smallX; |
| 95 |
|
|
dy = bigY - smallY; |
| 96 |
|
|
dz = bigZ - smallZ; |
| 97 |
|
|
|
| 98 |
|
|
dsqr = (dx * dx) + (dy * dy) + (dz * dz); |
| 99 |
|
|
maxLength = sqrt( dsqr ); |
| 100 |
|
|
} |
| 101 |
|
|
|
| 102 |
|
|
void MoLocator::rotMe( double r[3], double A[3][3] ){ |
| 103 |
|
|
|
| 104 |
|
|
double rt[3]; |
| 105 |
|
|
int i,j; |
| 106 |
|
|
|
| 107 |
|
|
for(i=0; i<3 i++) rt[i] = r[i]; |
| 108 |
|
|
|
| 109 |
|
|
for(i=0; i<3; i++){ |
| 110 |
|
|
r[i] = 0.0; |
| 111 |
|
|
for(j=0; j<3; j++){ |
| 112 |
|
|
r[i] += A[i][j] * rt[j]; |
| 113 |
|
|
} |
| 114 |
|
|
} |
| 115 |
|
|
} |
| 116 |
|
|
|