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