ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/RigidBody.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/primitives/RigidBody.cpp (file contents):
Revision 1937 by tim, Thu Jan 13 19:40:37 2005 UTC vs.
Revision 2018 by tim, Mon Feb 14 17:57:01 2005 UTC

# Line 172 | Line 172 | void  RigidBody::calcRefCoords() {
172          Itmp(0, 0) += mtmp * r2;
173          Itmp(1, 1) += mtmp * r2;
174          Itmp(2, 2) += mtmp * r2;
175 +    }
176 +
177 +    //project the inertial moment of directional atoms into this rigid body
178 +    for (std::size_t i = 0; i < atoms_.size(); i++) {
179 +        if (atoms_[i]->isDirectional()) {
180 +            RectMatrix<double, 3, 3> Iproject = refOrients_[i].transpose() * atoms_[i]->getI();
181 +            Itmp(0, 0) += Iproject(0, 0);
182 +            Itmp(1, 1) += Iproject(1, 1);
183 +            Itmp(2, 2) += Iproject(2, 2);
184 +        }
185      }
186  
187      //diagonalize
# Line 264 | Line 274 | void  RigidBody::updateAtoms() {
274            dAtom = (DirectionalAtom *) atoms_[i];
275            dAtom->setA(a * refOrients_[i]);
276            //dAtom->rotateBy( A );      
277 +        }
278 +
279 +    }
280 +  
281 + }
282 +
283 +
284 + void  RigidBody::updateAtoms(int frame) {
285 +    unsigned int i;
286 +    Vector3d ref;
287 +    Vector3d apos;
288 +    DirectionalAtom* dAtom;
289 +    Vector3d pos = getPos(frame);
290 +    RotMat3x3d a = getA(frame);
291 +    
292 +    for (i = 0; i < atoms_.size(); i++) {
293 +    
294 +        ref = body2Lab(refCoords_[i], frame);
295 +
296 +        apos = pos + ref;
297 +
298 +        atoms_[i]->setPos(apos, frame);
299 +
300 +        if (atoms_[i]->isDirectional()) {
301 +          
302 +          dAtom = (DirectionalAtom *) atoms_[i];
303 +          dAtom->setA(a * refOrients_[i], frame);
304          }
305  
306      }
307    
308 + }
309 +
310 + void RigidBody::updateAtomVel() {
311 +    Mat3x3d skewMat;;
312 +
313 +    Vector3d ji = getJ();
314 +    Mat3x3d I =  getI();
315 +
316 +    skewMat(0, 0) =0;
317 +    skewMat(0, 1) = ji[2] /I(2, 2);
318 +    skewMat(0, 2) = -ji[1] /I(1, 1);
319 +
320 +    skewMat(1, 0) = -ji[2] /I(2, 2);
321 +    skewMat(1, 1) = 0;
322 +    skewMat(1, 2) = ji[0]/I(0, 0);
323 +
324 +    skewMat(2, 0) =ji[1] /I(1, 1);
325 +    skewMat(2, 1) = -ji[0]/I(0, 0);
326 +    skewMat(2, 2) = 0;
327 +
328 +    Mat3x3d mat = (getA() * skewMat).transpose();
329 +    Vector3d rbVel = getVel();
330 +
331 +
332 +    Vector3d velRot;        
333 +    for (int i =0 ; i < refCoords_.size(); ++i) {
334 +        atoms_[i]->setVel(rbVel + mat * refCoords_[i]);
335 +    }
336 +
337   }
338  
339 + void RigidBody::updateAtomVel(int frame) {
340 +    Mat3x3d skewMat;;
341  
342 +    Vector3d ji = getJ(frame);
343 +    Mat3x3d I =  getI();
344 +
345 +    skewMat(0, 0) =0;
346 +    skewMat(0, 1) = ji[2] /I(2, 2);
347 +    skewMat(0, 2) = -ji[1] /I(1, 1);
348 +
349 +    skewMat(1, 0) = -ji[2] /I(2, 2);
350 +    skewMat(1, 1) = 0;
351 +    skewMat(1, 2) = ji[0]/I(0, 0);
352 +
353 +    skewMat(2, 0) =ji[1] /I(1, 1);
354 +    skewMat(2, 1) = -ji[0]/I(0, 0);
355 +    skewMat(2, 2) = 0;
356 +
357 +    Mat3x3d mat = (getA(frame) * skewMat).transpose();
358 +    Vector3d rbVel = getVel(frame);
359 +
360 +
361 +    Vector3d velRot;        
362 +    for (int i =0 ; i < refCoords_.size(); ++i) {
363 +        atoms_[i]->setVel(rbVel + mat * refCoords_[i], frame);
364 +    }
365 +
366 + }
367 +
368 +        
369 +
370   bool RigidBody::getAtomPos(Vector3d& pos, unsigned int index) {
371      if (index < atoms_.size()) {
372  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines