--- trunk/OOPSE/libmdtools/RigidBody.cpp 2004/04/15 16:18:26 1113 +++ trunk/OOPSE/libmdtools/RigidBody.cpp 2004/04/19 03:52:27 1118 @@ -6,6 +6,8 @@ RigidBody::RigidBody() : StuntDouble() { RigidBody::RigidBody() : StuntDouble() { objType = OT_RIGIDBODY; + is_linear = false; + linear_axis = -1; } RigidBody::~RigidBody() { \ No newline at end of file @@ -261,7 +263,7 @@ void RigidBody::calcRefCoords( ) { void RigidBody::calcRefCoords( ) { - int i,j,k, it; + int i,j,k, it, n_linear_coords; double mtmp; vec3 apos; double refCOM[3]; \ No newline at end of file @@ -328,11 +330,33 @@ void RigidBody::calcRefCoords( ) { // zero out I and then fill the diagonals with the moments of inertia: + n_linear_coords = 0; + for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { I[i][j] = 0.0; } I[i][i] = evals[i]; + + if (fabs(evals[i]) < momIntTol) { + is_linear = true; + n_linear_coords++; + linear_axis = i; + } + } + + if (n_linear_coords > 1) { + sprintf( painCave.errMsg, + "RigidBody error.\n" + "\tOOPSE found more than one axis in this rigid body with a vanishing \n" + "\tmoment of inertia. This can happen in one of three ways:\n" + "\t 1) Only one atom was specified, or \n" + "\t 2) All atoms were specified at the same location, or\n" + "\t 3) The programmers did something stupid.\n" + "\tIt is silly to use a rigid body to describe this situation. Be smarter.\n" + ); + painCave.isFatal = 1; + simError(); } // renormalize column vectors: \ No newline at end of file @@ -601,3 +625,11 @@ void RigidBody::findCOM() { } } + +void RigidBody::accept(BaseVisitor* v){ + vector::iterator atomIter; + v->visit(this); + + for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter) + (*atomIter)->accept(v); +} \ No newline at end of file