34 |
|
setTemp = 0; |
35 |
|
thermalTime = 0.0; |
36 |
|
rCut = 0.0; |
37 |
+ |
ecr = 0.0; |
38 |
+ |
est = 0.0; |
39 |
|
|
40 |
|
usePBC = 0; |
41 |
|
useLJ = 0; |
49 |
|
} |
50 |
|
|
51 |
|
void SimInfo::setBox(double newBox[3]) { |
52 |
+ |
|
53 |
+ |
int i, j; |
54 |
+ |
double tempMat[3][3]; |
55 |
|
|
56 |
< |
double smallestBoxL, maxCutoff; |
57 |
< |
int status; |
53 |
< |
int i; |
56 |
> |
for(i=0; i<3; i++) |
57 |
> |
for (j=0; j<3; j++) tempMat[i][j] = 0.0;; |
58 |
|
|
59 |
< |
for(i=0; i<9; i++) Hmat[i] = 0.0;; |
59 |
> |
tempMat[0][0] = newBox[0]; |
60 |
> |
tempMat[1][1] = newBox[1]; |
61 |
> |
tempMat[2][2] = newBox[2]; |
62 |
|
|
63 |
< |
Hmat[0] = newBox[0]; |
58 |
< |
Hmat[4] = newBox[1]; |
59 |
< |
Hmat[8] = newBox[2]; |
63 |
> |
setBoxM( tempMat ); |
64 |
|
|
65 |
< |
calcHmatI(); |
62 |
< |
calcBoxL(); |
65 |
> |
} |
66 |
|
|
67 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
67 |
> |
void SimInfo::setBoxM( double theBox[3][3] ){ |
68 |
> |
|
69 |
> |
int i, j, status; |
70 |
> |
double smallestBoxL, maxCutoff; |
71 |
> |
double FortranHmat[9]; // to preserve compatibility with Fortran the |
72 |
> |
// ordering in the array is as follows: |
73 |
> |
// [ 0 3 6 ] |
74 |
> |
// [ 1 4 7 ] |
75 |
> |
// [ 2 5 8 ] |
76 |
> |
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
77 |
|
|
66 |
– |
smallestBoxL = boxLx; |
67 |
– |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
68 |
– |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
78 |
|
|
79 |
< |
maxCutoff = smallestBoxL / 2.0; |
79 |
> |
for(i=0; i < 3; i++) |
80 |
> |
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
81 |
> |
|
82 |
> |
// cerr |
83 |
> |
// << "setting Hmat ->\n" |
84 |
> |
// << "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n" |
85 |
> |
// << "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n" |
86 |
> |
// << "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n"; |
87 |
|
|
88 |
< |
if (rList > maxCutoff) { |
89 |
< |
sprintf( painCave.errMsg, |
74 |
< |
"New Box size is forcing neighborlist radius down to %lf\n", |
75 |
< |
maxCutoff ); |
76 |
< |
painCave.isFatal = 0; |
77 |
< |
simError(); |
88 |
> |
calcBoxL(); |
89 |
> |
calcHmatInv(); |
90 |
|
|
91 |
< |
rList = maxCutoff; |
92 |
< |
|
93 |
< |
sprintf( painCave.errMsg, |
94 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
83 |
< |
maxCutoff - 1.0 ); |
84 |
< |
painCave.isFatal = 0; |
85 |
< |
simError(); |
86 |
< |
|
87 |
< |
rCut = rList - 1.0; |
88 |
< |
|
89 |
< |
// list radius changed so we have to refresh the simulation structure. |
90 |
< |
refreshSim(); |
91 |
< |
} |
92 |
< |
|
93 |
< |
if (rCut > maxCutoff) { |
94 |
< |
sprintf( painCave.errMsg, |
95 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
96 |
< |
maxCutoff ); |
97 |
< |
painCave.isFatal = 0; |
98 |
< |
simError(); |
99 |
< |
|
100 |
< |
status = 0; |
101 |
< |
LJ_new_rcut(&rCut, &status); |
102 |
< |
if (status != 0) { |
103 |
< |
sprintf( painCave.errMsg, |
104 |
< |
"Error in recomputing LJ shifts based on new rcut\n"); |
105 |
< |
painCave.isFatal = 1; |
106 |
< |
simError(); |
91 |
> |
for(i=0; i < 3; i++) { |
92 |
> |
for (j=0; j < 3; j++) { |
93 |
> |
FortranHmat[3*j + i] = Hmat[i][j]; |
94 |
> |
FortranHmatInv[3*j + i] = HmatInv[i][j]; |
95 |
|
} |
96 |
|
} |
109 |
– |
} |
97 |
|
|
98 |
< |
void SimInfo::setBoxM( double theBox[9] ){ |
112 |
< |
|
113 |
< |
int i, status; |
114 |
< |
double smallestBoxL, maxCutoff; |
115 |
< |
|
116 |
< |
for(i=0; i<9; i++) Hmat[i] = theBox[i]; |
117 |
< |
calcHmatI(); |
118 |
< |
calcBoxL(); |
119 |
< |
|
120 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
98 |
> |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
99 |
|
|
100 |
< |
smallestBoxL = boxLx; |
101 |
< |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
102 |
< |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
100 |
> |
smallestBoxL = boxL[0]; |
101 |
> |
if (boxL[1] < smallestBoxL) smallestBoxL = boxL[1]; |
102 |
> |
if (boxL[2] > smallestBoxL) smallestBoxL = boxL[2]; |
103 |
|
|
104 |
|
maxCutoff = smallestBoxL / 2.0; |
105 |
|
|
109 |
|
maxCutoff ); |
110 |
|
painCave.isFatal = 0; |
111 |
|
simError(); |
134 |
– |
|
112 |
|
rList = maxCutoff; |
113 |
|
|
114 |
< |
sprintf( painCave.errMsg, |
138 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
139 |
< |
maxCutoff - 1.0 ); |
140 |
< |
painCave.isFatal = 0; |
141 |
< |
simError(); |
142 |
< |
|
143 |
< |
rCut = rList - 1.0; |
144 |
< |
|
145 |
< |
// list radius changed so we have to refresh the simulation structure. |
146 |
< |
refreshSim(); |
147 |
< |
} |
148 |
< |
|
149 |
< |
if (rCut > maxCutoff) { |
150 |
< |
sprintf( painCave.errMsg, |
151 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
152 |
< |
maxCutoff ); |
153 |
< |
painCave.isFatal = 0; |
154 |
< |
simError(); |
155 |
< |
|
156 |
< |
status = 0; |
157 |
< |
LJ_new_rcut(&rCut, &status); |
158 |
< |
if (status != 0) { |
114 |
> |
if (rCut > (rList - 1.0)) { |
115 |
|
sprintf( painCave.errMsg, |
116 |
< |
"Error in recomputing LJ shifts based on new rcut\n"); |
117 |
< |
painCave.isFatal = 1; |
116 |
> |
"New Box size is forcing LJ cutoff radius down to %lf\n", |
117 |
> |
rList - 1.0 ); |
118 |
> |
painCave.isFatal = 0; |
119 |
|
simError(); |
120 |
+ |
rCut = rList - 1.0; |
121 |
|
} |
122 |
< |
} |
122 |
> |
|
123 |
> |
if( ecr > (rList - 1.0) ){ |
124 |
> |
sprintf( painCave.errMsg, |
125 |
> |
"New Box size is forcing electrostaticCutoffRadius " |
126 |
> |
"down to %lf\n" |
127 |
> |
"electrostaticSkinThickness is now %lf\n", |
128 |
> |
rList - 1.0, 0.05*(rList-1.0) ); |
129 |
> |
painCave.isFatal = 0; |
130 |
> |
simError(); |
131 |
> |
ecr = maxCutoff; |
132 |
> |
est = 0.05 * ecr; |
133 |
> |
} |
134 |
> |
|
135 |
> |
// At least one of the radii changed, so we need a refresh: |
136 |
> |
refreshSim(); |
137 |
> |
} |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
< |
void SimInfo::getBoxM (double theBox[9]) { |
141 |
> |
void SimInfo::getBoxM (double theBox[3][3]) { |
142 |
|
|
143 |
< |
int i; |
144 |
< |
for(i=0; i<9; i++) theBox[i] = Hmat[i]; |
143 |
> |
int i, j; |
144 |
> |
for(i=0; i<3; i++) |
145 |
> |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
void SimInfo::scaleBox(double scale) { |
150 |
< |
double theBox[9]; |
151 |
< |
int i; |
150 |
> |
double theBox[3][3]; |
151 |
> |
int i, j; |
152 |
|
|
153 |
< |
for(i=0; i<9; i++) theBox[i] = Hmat[i]*scale; |
153 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
154 |
|
|
155 |
+ |
for(i=0; i<3; i++) |
156 |
+ |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
157 |
+ |
|
158 |
|
setBoxM(theBox); |
159 |
|
|
160 |
|
} |
161 |
|
|
162 |
< |
void SimInfo::calcHmatI( void ) { |
163 |
< |
|
164 |
< |
double C[3][3]; |
188 |
< |
double detHmat; |
189 |
< |
int i, j, k; |
162 |
> |
void SimInfo::calcHmatInv( void ) { |
163 |
> |
|
164 |
> |
int i,j; |
165 |
|
double smallDiag; |
166 |
|
double tol; |
167 |
|
double sanity[3][3]; |
168 |
|
|
169 |
< |
// calculate the adjunct of Hmat; |
169 |
> |
invertMat3( Hmat, HmatInv ); |
170 |
|
|
171 |
< |
C[0][0] = ( Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]); |
197 |
< |
C[1][0] = -( Hmat[1]*Hmat[8]) + (Hmat[7]*Hmat[2]); |
198 |
< |
C[2][0] = ( Hmat[1]*Hmat[5]) - (Hmat[4]*Hmat[2]); |
171 |
> |
// Check the inverse to make sure it is sane: |
172 |
|
|
173 |
< |
C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]); |
174 |
< |
C[1][1] = ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]); |
175 |
< |
C[2][1] = -( Hmat[0]*Hmat[5]) + (Hmat[3]*Hmat[2]); |
176 |
< |
|
177 |
< |
C[0][2] = ( Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]); |
178 |
< |
C[1][2] = -( Hmat[0]*Hmat[7]) + (Hmat[6]*Hmat[1]); |
179 |
< |
C[2][2] = ( Hmat[0]*Hmat[4]) - (Hmat[3]*Hmat[1]); |
180 |
< |
|
208 |
< |
// calcutlate the determinant of Hmat |
209 |
< |
|
210 |
< |
detHmat = 0.0; |
211 |
< |
for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0]; |
212 |
< |
|
213 |
< |
|
214 |
< |
// H^-1 = C^T / det(H) |
215 |
< |
|
216 |
< |
i=0; |
217 |
< |
for(j=0; j<3; j++){ |
218 |
< |
for(k=0; k<3; k++){ |
173 |
> |
matMul3( Hmat, HmatInv, sanity ); |
174 |
> |
|
175 |
> |
// check to see if Hmat is orthorhombic |
176 |
> |
|
177 |
> |
smallDiag = Hmat[0][0]; |
178 |
> |
if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; |
179 |
> |
if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; |
180 |
> |
tol = smallDiag * 1E-6; |
181 |
|
|
182 |
< |
HmatI[i] = C[j][k] / detHmat; |
183 |
< |
i++; |
182 |
> |
orthoRhombic = 1; |
183 |
> |
|
184 |
> |
for (i = 0; i < 3; i++ ) { |
185 |
> |
for (j = 0 ; j < 3; j++) { |
186 |
> |
if (i != j) { |
187 |
> |
if (orthoRhombic) { |
188 |
> |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
189 |
> |
} |
190 |
> |
} |
191 |
|
} |
192 |
|
} |
193 |
+ |
} |
194 |
|
|
195 |
< |
// sanity check |
195 |
> |
double SimInfo::matDet3(double a[3][3]) { |
196 |
> |
int i, j, k; |
197 |
> |
double determinant; |
198 |
|
|
199 |
< |
for(i=0; i<3; i++){ |
200 |
< |
for(j=0; j<3; j++){ |
199 |
> |
determinant = 0.0; |
200 |
> |
|
201 |
> |
for(i = 0; i < 3; i++) { |
202 |
> |
j = (i+1)%3; |
203 |
> |
k = (i+2)%3; |
204 |
> |
|
205 |
> |
determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]); |
206 |
> |
} |
207 |
> |
|
208 |
> |
return determinant; |
209 |
> |
} |
210 |
> |
|
211 |
> |
void SimInfo::invertMat3(double a[3][3], double b[3][3]) { |
212 |
> |
|
213 |
> |
int i, j, k, l, m, n; |
214 |
> |
double determinant; |
215 |
> |
|
216 |
> |
determinant = matDet3( a ); |
217 |
> |
|
218 |
> |
if (determinant == 0.0) { |
219 |
> |
sprintf( painCave.errMsg, |
220 |
> |
"Can't invert a matrix with a zero determinant!\n"); |
221 |
> |
painCave.isFatal = 1; |
222 |
> |
simError(); |
223 |
> |
} |
224 |
> |
|
225 |
> |
for (i=0; i < 3; i++) { |
226 |
> |
j = (i+1)%3; |
227 |
> |
k = (i+2)%3; |
228 |
> |
for(l = 0; l < 3; l++) { |
229 |
> |
m = (l+1)%3; |
230 |
> |
n = (l+2)%3; |
231 |
|
|
232 |
< |
sanity[i][j] = 0.0; |
231 |
< |
for(k=0; k<3; k++){ |
232 |
< |
sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k]; |
233 |
< |
} |
232 |
> |
b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant; |
233 |
|
} |
234 |
|
} |
235 |
+ |
} |
236 |
|
|
237 |
< |
cerr << "sanity => \n" |
238 |
< |
<< sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
239 |
< |
<< sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
240 |
< |
<< sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
241 |
< |
<< "\n"; |
242 |
< |
|
237 |
> |
void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) { |
238 |
> |
double r00, r01, r02, r10, r11, r12, r20, r21, r22; |
239 |
|
|
240 |
< |
// check to see if Hmat is orthorhombic |
240 |
> |
r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0]; |
241 |
> |
r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1]; |
242 |
> |
r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2]; |
243 |
|
|
244 |
< |
smallDiag = Hmat[0]; |
245 |
< |
if(smallDiag > Hmat[4]) smallDiag = Hmat[4]; |
246 |
< |
if(smallDiag > Hmat[8]) smallDiag = Hmat[8]; |
247 |
< |
tol = smallDiag * 1E-6; |
244 |
> |
r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0]; |
245 |
> |
r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1]; |
246 |
> |
r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2]; |
247 |
> |
|
248 |
> |
r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0]; |
249 |
> |
r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1]; |
250 |
> |
r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2]; |
251 |
> |
|
252 |
> |
c[0][0] = r00; c[0][1] = r01; c[0][2] = r02; |
253 |
> |
c[1][0] = r10; c[1][1] = r11; c[1][2] = r12; |
254 |
> |
c[2][0] = r20; c[2][1] = r21; c[2][2] = r22; |
255 |
> |
} |
256 |
|
|
257 |
< |
orthoRhombic = 1; |
258 |
< |
for(i=0; (i<9) && orthoRhombic; i++){ |
259 |
< |
|
260 |
< |
if( (i%4) ){ // ignore the diagonals (0, 4, and 8) |
261 |
< |
orthoRhombic = (Hmat[i] <= tol); |
257 |
> |
void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) { |
258 |
> |
double a0, a1, a2; |
259 |
> |
|
260 |
> |
a0 = inVec[0]; a1 = inVec[1]; a2 = inVec[2]; |
261 |
> |
|
262 |
> |
outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2; |
263 |
> |
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
264 |
> |
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
265 |
> |
} |
266 |
> |
|
267 |
> |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
268 |
> |
double temp[3][3]; |
269 |
> |
int i, j; |
270 |
> |
|
271 |
> |
for (i = 0; i < 3; i++) { |
272 |
> |
for (j = 0; j < 3; j++) { |
273 |
> |
temp[j][i] = in[i][j]; |
274 |
|
} |
275 |
|
} |
276 |
< |
|
276 |
> |
for (i = 0; i < 3; i++) { |
277 |
> |
for (j = 0; j < 3; j++) { |
278 |
> |
out[i][j] = temp[i][j]; |
279 |
> |
} |
280 |
> |
} |
281 |
|
} |
282 |
+ |
|
283 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
284 |
|
|
285 |
+ |
std::cerr |
286 |
+ |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
287 |
+ |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
288 |
+ |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
289 |
+ |
} |
290 |
+ |
|
291 |
+ |
void SimInfo::printMat9(double A[9] ){ |
292 |
+ |
|
293 |
+ |
std::cerr |
294 |
+ |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
295 |
+ |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
296 |
+ |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
297 |
+ |
} |
298 |
+ |
|
299 |
|
void SimInfo::calcBoxL( void ){ |
300 |
|
|
301 |
|
double dx, dy, dz, dsq; |
302 |
|
int i; |
303 |
|
|
304 |
< |
// boxVol = h1 (dot) h2 (cross) h3 |
304 |
> |
// boxVol = Determinant of Hmat |
305 |
|
|
306 |
< |
boxVol = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) ) |
269 |
< |
+ Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) ) |
270 |
< |
+ Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) ); |
306 |
> |
boxVol = matDet3( Hmat ); |
307 |
|
|
272 |
– |
|
308 |
|
// boxLx |
309 |
|
|
310 |
< |
dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2]; |
310 |
> |
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
311 |
|
dsq = dx*dx + dy*dy + dz*dz; |
312 |
< |
boxLx = sqrt( dsq ); |
312 |
> |
boxL[0] = sqrt( dsq ); |
313 |
|
|
314 |
|
// boxLy |
315 |
|
|
316 |
< |
dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5]; |
316 |
> |
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
317 |
|
dsq = dx*dx + dy*dy + dz*dz; |
318 |
< |
boxLy = sqrt( dsq ); |
318 |
> |
boxL[1] = sqrt( dsq ); |
319 |
|
|
320 |
|
// boxLz |
321 |
|
|
322 |
< |
dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8]; |
322 |
> |
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
323 |
|
dsq = dx*dx + dy*dy + dz*dz; |
324 |
< |
boxLz = sqrt( dsq ); |
324 |
> |
boxL[2] = sqrt( dsq ); |
325 |
|
|
326 |
|
} |
327 |
|
|
333 |
|
|
334 |
|
if( !orthoRhombic ){ |
335 |
|
// calc the scaled coordinates. |
336 |
+ |
|
337 |
+ |
|
338 |
+ |
matVecMul3(HmatInv, thePos, scaled); |
339 |
|
|
340 |
|
for(i=0; i<3; i++) |
303 |
– |
scaled[i] = |
304 |
– |
thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6]; |
305 |
– |
|
306 |
– |
// wrap the scaled coordinates |
307 |
– |
|
308 |
– |
for(i=0; i<3; i++) |
341 |
|
scaled[i] -= roundMe(scaled[i]); |
342 |
|
|
343 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
344 |
|
|
345 |
< |
for(i=0; i<3; i++) |
346 |
< |
thePos[i] = |
315 |
< |
scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6]; |
345 |
> |
matVecMul3(Hmat, scaled, thePos); |
346 |
> |
|
347 |
|
} |
348 |
|
else{ |
349 |
|
// calc the scaled coordinates. |
350 |
|
|
351 |
|
for(i=0; i<3; i++) |
352 |
< |
scaled[i] = thePos[i]*HmatI[i*4]; |
352 |
> |
scaled[i] = thePos[i]*HmatInv[i][i]; |
353 |
|
|
354 |
|
// wrap the scaled coordinates |
355 |
|
|
359 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
360 |
|
|
361 |
|
for(i=0; i<3; i++) |
362 |
< |
thePos[i] = scaled[i]*Hmat[i*4]; |
362 |
> |
thePos[i] = scaled[i]*Hmat[i][i]; |
363 |
|
} |
364 |
|
|
334 |
– |
|
365 |
|
} |
366 |
|
|
367 |
|
|