| 1 |
< |
/* |
| 1 |
> |
/* |
| 2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
| 3 |
|
* |
| 4 |
|
* The University of Notre Dame grants you ("Licensee") a |
| 55 |
|
#include "primitives/DirectionalAtom.hpp" |
| 56 |
|
#include "types/AtomStamp.hpp" |
| 57 |
|
namespace oopse{ |
| 58 |
< |
class RigidBody : public StuntDouble { |
| 59 |
< |
public: |
| 58 |
> |
class RigidBody : public StuntDouble { |
| 59 |
> |
public: |
| 60 |
|
|
| 61 |
< |
typedef std::vector<Atom*>::iterator AtomIterator; |
| 61 |
> |
typedef std::vector<Atom*>::iterator AtomIterator; |
| 62 |
|
|
| 63 |
< |
RigidBody(); |
| 63 |
> |
RigidBody(); |
| 64 |
|
|
| 65 |
< |
virtual std::string getType() { return name_;} |
| 65 |
> |
virtual std::string getType() { return name_;} |
| 66 |
|
|
| 67 |
< |
/** Sets the name of this stuntdouble*/ |
| 68 |
< |
virtual void setType(const std::string& name) { name_ = name;} |
| 67 |
> |
/** Sets the name of this stuntdouble*/ |
| 68 |
> |
virtual void setType(const std::string& name) { name_ = name;} |
| 69 |
|
|
| 70 |
|
|
| 71 |
< |
/** |
| 72 |
< |
* Sets the previous rotation matrix of this stuntdouble |
| 73 |
< |
* @param a new rotation matrix |
| 74 |
< |
*/ |
| 75 |
< |
virtual void setPrevA(const RotMat3x3d& a); |
| 71 |
> |
/** |
| 72 |
> |
* Sets the previous rotation matrix of this stuntdouble |
| 73 |
> |
* @param a new rotation matrix |
| 74 |
> |
*/ |
| 75 |
> |
virtual void setPrevA(const RotMat3x3d& a); |
| 76 |
|
|
| 77 |
< |
/** |
| 78 |
< |
* Sets the current rotation matrix of this stuntdouble |
| 79 |
< |
* @param a new rotation matrix |
| 80 |
< |
* @note setA will not change the position and rotation matrix of Directional atoms belong to |
| 81 |
< |
* this rigidbody. If you want to do that, use #updateAtoms |
| 82 |
< |
*/ |
| 83 |
< |
virtual void setA(const RotMat3x3d& a); |
| 84 |
< |
/** |
| 85 |
< |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
| 86 |
< |
* @param a rotation matrix to be set |
| 87 |
< |
* @param snapshotNo |
| 88 |
< |
* @see #getA |
| 89 |
< |
*/ |
| 90 |
< |
virtual void setA(const RotMat3x3d& a, int snapshotNo); |
| 77 |
> |
/** |
| 78 |
> |
* Sets the current rotation matrix of this stuntdouble |
| 79 |
> |
* @param a new rotation matrix |
| 80 |
> |
* @note setA will not change the position and rotation matrix of Directional atoms belong to |
| 81 |
> |
* this rigidbody. If you want to do that, use #updateAtoms |
| 82 |
> |
*/ |
| 83 |
> |
virtual void setA(const RotMat3x3d& a); |
| 84 |
> |
/** |
| 85 |
> |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
| 86 |
> |
* @param a rotation matrix to be set |
| 87 |
> |
* @param snapshotNo |
| 88 |
> |
* @see #getA |
| 89 |
> |
*/ |
| 90 |
> |
virtual void setA(const RotMat3x3d& a, int snapshotNo); |
| 91 |
|
|
| 92 |
< |
/** |
| 93 |
< |
* Returns the inertia tensor of this stuntdouble |
| 94 |
< |
* @return the inertia tensor of this stuntdouble |
| 95 |
< |
*/ |
| 96 |
< |
virtual Mat3x3d getI(); |
| 92 |
> |
/** |
| 93 |
> |
* Returns the inertia tensor of this stuntdouble |
| 94 |
> |
* @return the inertia tensor of this stuntdouble |
| 95 |
> |
*/ |
| 96 |
> |
virtual Mat3x3d getI(); |
| 97 |
|
|
| 98 |
|
|
| 99 |
< |
/** Sets the internal unit frame of this stuntdouble by three euler angles */ |
| 100 |
< |
void setElectroFrameFromEuler(double phi, double theta, double psi); |
| 99 |
> |
/** Sets the internal unit frame of this stuntdouble by three euler angles */ |
| 100 |
> |
void setElectroFrameFromEuler(double phi, double theta, double psi); |
| 101 |
|
|
| 102 |
< |
/** |
| 103 |
< |
* Returns the gradient of this stuntdouble |
| 104 |
< |
* @return the inertia tensor of this stuntdouble |
| 105 |
< |
* @see #setI |
| 106 |
< |
*/ |
| 107 |
< |
virtual std::vector<double> getGrad(); |
| 102 |
> |
/** |
| 103 |
> |
* Returns the gradient of this stuntdouble |
| 104 |
> |
* @return the inertia tensor of this stuntdouble |
| 105 |
> |
* @see #setI |
| 106 |
> |
*/ |
| 107 |
> |
virtual std::vector<double> getGrad(); |
| 108 |
|
|
| 109 |
< |
virtual void accept(BaseVisitor* v); |
| 109 |
> |
virtual void accept(BaseVisitor* v); |
| 110 |
|
|
| 111 |
< |
void addAtom(Atom* at, AtomStamp* ats); |
| 111 |
> |
void addAtom(Atom* at, AtomStamp* ats); |
| 112 |
|
|
| 113 |
< |
/** calculate the reference coordinates */ |
| 114 |
< |
void calcRefCoords(); |
| 113 |
> |
/** calculate the reference coordinates */ |
| 114 |
> |
void calcRefCoords(); |
| 115 |
|
|
| 116 |
< |
/** Convert Atomic forces and torques to total forces and torques */ |
| 117 |
< |
void calcForcesAndTorques(); |
| 116 |
> |
/** Convert Atomic forces and torques to total forces and torques */ |
| 117 |
> |
void calcForcesAndTorques(); |
| 118 |
|
|
| 119 |
< |
/** update the positions of atoms belong to this rigidbody */ |
| 120 |
< |
void updateAtoms(); |
| 119 |
> |
/** update the positions of atoms belong to this rigidbody */ |
| 120 |
> |
void updateAtoms(); |
| 121 |
|
|
| 122 |
< |
Atom* beginAtom(std::vector<Atom*>::iterator& i) { |
| 123 |
< |
i = atoms_.begin(); |
| 124 |
< |
return i != atoms_.end() ? *i : NULL; |
| 125 |
< |
} |
| 122 |
> |
void updateAtoms(int frame); |
| 123 |
|
|
| 124 |
< |
Atom* nextAtom(std::vector<Atom*>::iterator& i) { |
| 128 |
< |
++i; |
| 129 |
< |
return i != atoms_.end() ? *i : NULL; |
| 130 |
< |
} |
| 124 |
> |
void updateAtomVel(); |
| 125 |
|
|
| 126 |
< |
std::vector<Atom*>::iterator getBeginAtomIter() { |
| 133 |
< |
return atoms_.begin(); |
| 134 |
< |
} |
| 126 |
> |
void updateAtomVel(int frame); |
| 127 |
|
|
| 128 |
< |
std::vector<Atom*>::iterator getEndAtomIter() { |
| 129 |
< |
return atoms_.end(); |
| 130 |
< |
} |
| 128 |
> |
Atom* beginAtom(std::vector<Atom*>::iterator& i) { |
| 129 |
> |
i = atoms_.begin(); |
| 130 |
> |
return i != atoms_.end() ? *i : NULL; |
| 131 |
> |
} |
| 132 |
|
|
| 133 |
< |
/** |
| 134 |
< |
* Returns the atoms of this rigid body |
| 135 |
< |
* @return the atoms of this rigid body in a vector |
| 136 |
< |
* @deprecate |
| 144 |
< |
*/ |
| 145 |
< |
std::vector<Atom*> getAtoms() { |
| 146 |
< |
return atoms_; |
| 147 |
< |
} |
| 133 |
> |
Atom* nextAtom(std::vector<Atom*>::iterator& i) { |
| 134 |
> |
++i; |
| 135 |
> |
return i != atoms_.end() ? *i : NULL; |
| 136 |
> |
} |
| 137 |
|
|
| 138 |
< |
/** |
| 139 |
< |
* Returns the number of atoms in this rigid body |
| 140 |
< |
* @return the number of atoms in this rigid body |
| 141 |
< |
*/ |
| 142 |
< |
int getNumAtoms() { |
| 143 |
< |
return atoms_.size(); |
| 144 |
< |
} |
| 138 |
> |
std::vector<Atom*>::iterator getBeginAtomIter() { |
| 139 |
> |
return atoms_.begin(); |
| 140 |
> |
} |
| 141 |
> |
|
| 142 |
> |
std::vector<Atom*>::iterator getEndAtomIter() { |
| 143 |
> |
return atoms_.end(); |
| 144 |
> |
} |
| 145 |
|
|
| 146 |
< |
/** |
| 147 |
< |
* Return the position of atom which belongs to this rigid body. |
| 148 |
< |
* @return true if index is valid otherwise return false |
| 149 |
< |
* @param pos the position of atom which will be set on return if index is valid |
| 150 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 151 |
< |
*/ |
| 152 |
< |
bool getAtomPos(Vector3d& pos, unsigned int index); |
| 146 |
> |
/** |
| 147 |
> |
* Returns the atoms of this rigid body |
| 148 |
> |
* @return the atoms of this rigid body in a vector |
| 149 |
> |
* @deprecate |
| 150 |
> |
*/ |
| 151 |
> |
std::vector<Atom*> getAtoms() { |
| 152 |
> |
return atoms_; |
| 153 |
> |
} |
| 154 |
|
|
| 155 |
< |
/** |
| 156 |
< |
* Return the position of atom which belongs to this rigid body. |
| 157 |
< |
* @return true if atom belongs to this rigid body,otherwise return false |
| 158 |
< |
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
| 159 |
< |
* @param atom the pointer to an atom |
| 160 |
< |
*/ |
| 161 |
< |
bool getAtomPos(Vector3d& pos, Atom* atom); |
| 155 |
> |
/** |
| 156 |
> |
* Returns the number of atoms in this rigid body |
| 157 |
> |
* @return the number of atoms in this rigid body |
| 158 |
> |
*/ |
| 159 |
> |
int getNumAtoms() { |
| 160 |
> |
return atoms_.size(); |
| 161 |
> |
} |
| 162 |
|
|
| 163 |
< |
/** |
| 164 |
< |
* Return the velocity of atom which belongs to this rigid body. |
| 165 |
< |
* @return true if index is valid otherwise return false |
| 166 |
< |
* @param vel the velocity of atom which will be set on return if index is valid |
| 167 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 168 |
< |
*/ |
| 169 |
< |
bool getAtomVel(Vector3d& vel, unsigned int index); |
| 163 |
> |
/** |
| 164 |
> |
* Return the position of atom which belongs to this rigid body. |
| 165 |
> |
* @return true if index is valid otherwise return false |
| 166 |
> |
* @param pos the position of atom which will be set on return if index is valid |
| 167 |
> |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 168 |
> |
*/ |
| 169 |
> |
bool getAtomPos(Vector3d& pos, unsigned int index); |
| 170 |
|
|
| 171 |
< |
/** |
| 172 |
< |
* Return the velocity of atom which belongs to this rigid body. |
| 173 |
< |
* @return true if atom belongs to this rigid body,otherwise return false |
| 174 |
< |
* @param vel velocity of atom which will be set on return if atom belongs to this rigid body |
| 175 |
< |
* @param atom the pointer to an atom |
| 176 |
< |
*/ |
| 177 |
< |
bool getAtomVel(Vector3d& vel, Atom*); |
| 171 |
> |
/** |
| 172 |
> |
* Return the position of atom which belongs to this rigid body. |
| 173 |
> |
* @return true if atom belongs to this rigid body,otherwise return false |
| 174 |
> |
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
| 175 |
> |
* @param atom the pointer to an atom |
| 176 |
> |
*/ |
| 177 |
> |
bool getAtomPos(Vector3d& pos, Atom* atom); |
| 178 |
|
|
| 179 |
< |
/** |
| 180 |
< |
* Return the reference coordinate of atom which belongs to this rigid body. |
| 181 |
< |
* @return true if index is valid otherwise return false |
| 182 |
< |
* @param coor the reference coordinate of atom which will be set on return if index is valid |
| 183 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 184 |
< |
*/ |
| 185 |
< |
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
| 179 |
> |
/** |
| 180 |
> |
* Return the velocity of atom which belongs to this rigid body. |
| 181 |
> |
* @return true if index is valid otherwise return false |
| 182 |
> |
* @param vel the velocity of atom which will be set on return if index is valid |
| 183 |
> |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 184 |
> |
*/ |
| 185 |
> |
bool getAtomVel(Vector3d& vel, unsigned int index); |
| 186 |
|
|
| 187 |
< |
/** |
| 188 |
< |
* Return the velocity of atom which belongs to this rigid body. |
| 189 |
< |
* @return true if atom belongs to this rigid body,otherwise return false |
| 190 |
< |
* @param coor velocity of atom which will be set on return if atom belongs to this rigid body |
| 191 |
< |
* @param atom the pointer to an atom |
| 192 |
< |
*/ |
| 193 |
< |
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
| 187 |
> |
/** |
| 188 |
> |
* Return the velocity of atom which belongs to this rigid body. |
| 189 |
> |
* @return true if atom belongs to this rigid body,otherwise return false |
| 190 |
> |
* @param vel velocity of atom which will be set on return if atom belongs to this rigid body |
| 191 |
> |
* @param atom the pointer to an atom |
| 192 |
> |
*/ |
| 193 |
> |
bool getAtomVel(Vector3d& vel, Atom*); |
| 194 |
|
|
| 195 |
< |
private: |
| 196 |
< |
std::string name_; |
| 197 |
< |
Mat3x3d inertiaTensor_; |
| 198 |
< |
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
| 195 |
> |
/** |
| 196 |
> |
* Return the reference coordinate of atom which belongs to this rigid body. |
| 197 |
> |
* @return true if index is valid otherwise return false |
| 198 |
> |
* @param coor the reference coordinate of atom which will be set on return if index is valid |
| 199 |
> |
* @param index the index of the atom in rigid body's private data member atoms_ |
| 200 |
> |
*/ |
| 201 |
> |
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
| 202 |
> |
|
| 203 |
> |
/** |
| 204 |
> |
* Return the velocity of atom which belongs to this rigid body. |
| 205 |
> |
* @return true if atom belongs to this rigid body,otherwise return false |
| 206 |
> |
* @param coor velocity of atom which will be set on return if atom belongs to this rigid body |
| 207 |
> |
* @param atom the pointer to an atom |
| 208 |
> |
*/ |
| 209 |
> |
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
| 210 |
> |
|
| 211 |
> |
private: |
| 212 |
> |
std::string name_; |
| 213 |
> |
Mat3x3d inertiaTensor_; |
| 214 |
> |
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
| 215 |
|
|
| 216 |
< |
std::vector<Atom*> atoms_; |
| 217 |
< |
std::vector<Vector3d> refCoords_; |
| 218 |
< |
std::vector<RotMat3x3d> refOrients_; |
| 219 |
< |
}; |
| 216 |
> |
std::vector<Atom*> atoms_; |
| 217 |
> |
std::vector<Vector3d> refCoords_; |
| 218 |
> |
std::vector<RotMat3x3d> refOrients_; |
| 219 |
> |
}; |
| 220 |
|
|
| 221 |
|
}//namepace oopse |
| 222 |
|
|