1 |
tim |
1692 |
/* |
2 |
|
|
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
|
|
* |
4 |
|
|
* Contact: oopse@oopse.org |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2.1 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* All we ask is that proper credit is given for our work, which includes |
11 |
|
|
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
|
|
* of your source code files, and to any copyright notice that you may distribute |
13 |
|
|
* with programs based on this work. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU Lesser General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
21 |
|
|
* along with this program; if not, write to the Free Software |
22 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
|
|
* |
24 |
|
|
*/ |
25 |
gezelter |
1490 |
|
26 |
tim |
1692 |
/** |
27 |
|
|
* @file RigidBody.hpp |
28 |
|
|
* @author tlin |
29 |
|
|
* @date 10/23/2004 |
30 |
|
|
* @version 1.0 |
31 |
|
|
*/ |
32 |
gezelter |
1490 |
|
33 |
tim |
1692 |
#ifndef PRIMITIVES_RIGIDBODY_HPP |
34 |
|
|
#define PRIMITIVES_RIGIDBODY_HPP |
35 |
gezelter |
1490 |
|
36 |
tim |
1692 |
#include <vector> |
37 |
gezelter |
1490 |
|
38 |
tim |
1692 |
#include "primitives/StuntDouble.hpp" |
39 |
|
|
#include "primitives/DirectionalAtom.hpp" |
40 |
|
|
namespace oopse{ |
41 |
|
|
class RigidBody : public StuntDouble { |
42 |
|
|
public: |
43 |
|
|
RigidBody(); |
44 |
gezelter |
1490 |
|
45 |
tim |
1692 |
/** |
46 |
|
|
* Sets the previous rotation matrix of this stuntdouble |
47 |
|
|
* @param a new rotation matrix |
48 |
|
|
*/ |
49 |
|
|
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); |
63 |
gezelter |
1490 |
|
64 |
tim |
1692 |
/** |
65 |
|
|
* Returns the inertia tensor of this stuntdouble |
66 |
|
|
* @return the inertia tensor of this stuntdouble |
67 |
|
|
*/ |
68 |
|
|
virtual Mat3x3d getI(); |
69 |
gezelter |
1490 |
|
70 |
|
|
|
71 |
tim |
1692 |
/** 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(); |
80 |
gezelter |
1490 |
|
81 |
tim |
1692 |
virtual void accept(BaseVisitor* v); |
82 |
gezelter |
1490 |
|
83 |
tim |
1692 |
void addAtom(Atom* atom); |
84 |
gezelter |
1490 |
|
85 |
tim |
1692 |
/** calculate the reference coordinates */ |
86 |
|
|
void calcRefCoords(); |
87 |
gezelter |
1490 |
|
88 |
tim |
1692 |
/** Convert Atomic forces and torques to total forces and torques */ |
89 |
|
|
void calcForcesAndTorques(); |
90 |
gezelter |
1490 |
|
91 |
tim |
1692 |
/** update the positions of atoms belong to this rigidbody */ |
92 |
|
|
void updateAtoms(); |
93 |
gezelter |
1490 |
|
94 |
tim |
1695 |
Atom* beginAtom(std::vector<Atom*>::iterator& i); |
95 |
|
|
|
96 |
|
|
Atom* nextAtom(std::vector<Atom*>::iterator& i); |
97 |
|
|
|
98 |
|
|
std::vector<Atom*>::iterator getBeginAtomIter() { |
99 |
|
|
return atoms_.begin(); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
std::vector<Atom*>::iterator getEndAtomIter() { |
103 |
|
|
return atoms_.end(); |
104 |
|
|
} |
105 |
|
|
|
106 |
tim |
1692 |
/** |
107 |
|
|
* Returns the atoms of this rigid body |
108 |
|
|
* @return the atoms of this rigid body in a vector |
109 |
tim |
1695 |
* @deprecate |
110 |
tim |
1692 |
*/ |
111 |
|
|
std::vector<Atom*> getAtoms() { |
112 |
|
|
return atoms_; |
113 |
|
|
} |
114 |
gezelter |
1490 |
|
115 |
tim |
1692 |
/** |
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 |
|
|
} |
122 |
gezelter |
1490 |
|
123 |
tim |
1692 |
/** |
124 |
|
|
* Return the position of atom which belongs to this rigid body. |
125 |
|
|
* @return true if index is valid otherwise return false |
126 |
|
|
* @param pos the position of atom which will be set on return if index is valid |
127 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
128 |
|
|
*/ |
129 |
|
|
bool getAtomPos(Vector3d& pos, unsigned int index); |
130 |
gezelter |
1490 |
|
131 |
tim |
1692 |
/** |
132 |
|
|
* Return the position of atom which belongs to this rigid body. |
133 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
134 |
|
|
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
135 |
|
|
* @param atom the pointer to an atom |
136 |
|
|
*/ |
137 |
|
|
bool getAtomPos(Vector3d& pos, Atom* atom); |
138 |
gezelter |
1490 |
|
139 |
tim |
1692 |
/** |
140 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
141 |
|
|
* @return true if index is valid otherwise return false |
142 |
|
|
* @param vel the velocity of atom which will be set on return if index is valid |
143 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
144 |
|
|
*/ |
145 |
|
|
bool getAtomVel(Vector3d& vel, unsigned int index); |
146 |
gezelter |
1490 |
|
147 |
tim |
1692 |
/** |
148 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
149 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
150 |
|
|
* @param vel velocity of atom which will be set on return if atom belongs to this rigid body |
151 |
|
|
* @param atom the pointer to an atom |
152 |
|
|
*/ |
153 |
|
|
bool getAtomVel(Vector3d& vel, Atom*); |
154 |
gezelter |
1490 |
|
155 |
tim |
1692 |
/** |
156 |
|
|
* Return the reference coordinate of atom which belongs to this rigid body. |
157 |
|
|
* @return true if index is valid otherwise return false |
158 |
|
|
* @param coor the reference coordinate of atom which will be set on return if index is valid |
159 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
160 |
|
|
*/ |
161 |
|
|
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
162 |
gezelter |
1490 |
|
163 |
tim |
1692 |
/** |
164 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
165 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
166 |
|
|
* @param coor velocity of atom which will be set on return if atom belongs to this rigid body |
167 |
|
|
* @param atom the pointer to an atom |
168 |
|
|
*/ |
169 |
|
|
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
170 |
gezelter |
1490 |
|
171 |
tim |
1692 |
private: |
172 |
|
|
|
173 |
|
|
Mat3x3d inertiaTensor_; |
174 |
|
|
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
175 |
|
|
|
176 |
|
|
std::vector<Atom*> atoms_; |
177 |
|
|
std::vector<Vector3d> refCoords_; |
178 |
|
|
}; |
179 |
gezelter |
1490 |
|
180 |
tim |
1692 |
}//namepace oopse |
181 |
gezelter |
1490 |
|
182 |
tim |
1692 |
#endif //PRIMITIVES_RIGIDBODY_HPP |
183 |
gezelter |
1490 |
|