65 |
|
/** |
66 |
|
* @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp" |
67 |
|
* @brief |
68 |
+ |
* "Don't move, or you're dead! Stand up! Captain, we've got them!" |
69 |
+ |
* |
70 |
+ |
* "Spectacular stunt, my friends, but all for naught. Turn around |
71 |
+ |
* please. Ha. What a pity. What a pity. So, Princess, you thought |
72 |
+ |
* you could outwit the imperious forces of...." |
73 |
+ |
* |
74 |
+ |
* "You idiots! These are not them. You've captured their stunt |
75 |
+ |
* doubles! Search the area. Find them! Find them!" |
76 |
+ |
* |
77 |
|
* StuntDouble is a very strange idea. A StuntDouble stands in for |
78 |
|
* some object that can be manipulated by the Integrators or |
79 |
|
* Minimizers. Some of the manipulable objects are Atoms, some are |
80 |
|
* DirectionalAtoms, and some are RigidBodies. StuntDouble |
81 |
|
* provides an interface for the Integrators and Minimizers to use, |
82 |
|
* and does some preliminary sanity checking so that the program |
83 |
< |
* doesn't try to do something stupid like torque an Atom |
83 |
> |
* doesn't try to do something stupid like torque an Atom (The |
84 |
> |
* quotes above are from Spaceballs...) |
85 |
> |
* |
86 |
|
* @note the dynamic data of stuntdouble will be stored outside of the class |
87 |
|
*/ |
88 |
|
class StuntDouble{ |
97 |
|
virtual ~StuntDouble(); |
98 |
|
|
99 |
|
/** |
100 |
< |
* Returns the global index of this stuntdouble. |
100 |
> |
* Returns the global index of this stuntRealType. |
101 |
|
* @return the global index of this stuntdouble |
102 |
|
*/ |
103 |
|
int getGlobalIndex() { |
105 |
|
} |
106 |
|
|
107 |
|
/** |
108 |
< |
* Sets the global index of this stuntdouble. |
108 |
> |
* Sets the global index of this stuntRealType. |
109 |
|
* @param new global index to be set |
110 |
|
*/ |
111 |
|
void setGlobalIndex(int index) { |
128 |
|
localIndex_ = index; |
129 |
|
} |
130 |
|
|
131 |
+ |
int getGlobalIntegrableObjectIndex(){ |
132 |
+ |
return globalIntegrableObjectIndex_; |
133 |
+ |
} |
134 |
+ |
void setGlobalIntegrableObjectIndex(int index) { |
135 |
+ |
globalIntegrableObjectIndex_ = index; |
136 |
+ |
} |
137 |
+ |
|
138 |
|
/** |
139 |
|
* Sets the Snapshot Manager of this stuntdouble |
140 |
|
*/ |
172 |
|
*/ |
173 |
|
bool isDirectional(){ |
174 |
|
return isDirectionalAtom() || isRigidBody(); |
175 |
+ |
} |
176 |
+ |
|
177 |
+ |
/** |
178 |
+ |
* Freezes out all velocity, angular velocity, forces and torques |
179 |
+ |
* on this StuntDouble. Also computes the number of frozen degrees |
180 |
+ |
* of freedom. |
181 |
+ |
* @return the total number of frozen degrees of freedom |
182 |
+ |
*/ |
183 |
+ |
int freeze() { |
184 |
+ |
|
185 |
+ |
int fdf = 3; |
186 |
+ |
|
187 |
+ |
setVel(V3Zero); |
188 |
+ |
setFrc(V3Zero); |
189 |
+ |
if (isDirectional()){ |
190 |
+ |
setJ(V3Zero); |
191 |
+ |
setTrq(V3Zero); |
192 |
+ |
if (isLinear()) |
193 |
+ |
fdf +=2; |
194 |
+ |
else |
195 |
+ |
fdf +=3; |
196 |
+ |
} |
197 |
+ |
return fdf; |
198 |
|
} |
199 |
|
|
200 |
|
/** |
490 |
|
} |
491 |
|
|
492 |
|
/** |
493 |
< |
* Sets the previous euler angles of this stuntdouble. |
493 |
> |
* Sets the previous euler angles of this stuntRealType. |
494 |
|
* @param euler new euler angles |
495 |
|
* @see #getEuler |
496 |
|
* @note actual storage data is rotation matrix |
717 |
|
* Returns the previous z-angle of this stuntdouble |
718 |
|
* @return the z-angle of this stuntdouble |
719 |
|
*/ |
720 |
< |
double getPrevZangle() { |
720 |
> |
RealType getPrevZangle() { |
721 |
|
return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_]; |
722 |
|
} |
723 |
|
|
725 |
|
* Returns the current z-angle of this stuntdouble |
726 |
|
* @return the z-angle of this stuntdouble |
727 |
|
*/ |
728 |
< |
double getZangle() { |
728 |
> |
RealType getZangle() { |
729 |
|
return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_]; |
730 |
|
} |
731 |
|
|
734 |
|
* @return the z-angle of this stuntdouble |
735 |
|
* @param snapshotNo |
736 |
|
*/ |
737 |
< |
double getZangle(int snapshotNo) { |
737 |
> |
RealType getZangle(int snapshotNo) { |
738 |
|
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_]; |
739 |
|
} |
740 |
|
|
743 |
|
* @param angle new z-angle |
744 |
|
* @see #getZangle |
745 |
|
*/ |
746 |
< |
void setPrevZangle(double angle) { |
746 |
> |
void setPrevZangle(RealType angle) { |
747 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle; |
748 |
|
} |
749 |
|
|
751 |
|
* Sets the current z-angle of this stuntdouble |
752 |
|
* @param angle new z-angle |
753 |
|
*/ |
754 |
< |
void setZangle(double angle) { |
754 |
> |
void setZangle(RealType angle) { |
755 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle; |
756 |
|
} |
757 |
|
|
761 |
|
* @param snapshotNo |
762 |
|
* @see #getZangle |
763 |
|
*/ |
764 |
< |
void setZangle(double angle, int snapshotNo) { |
764 |
> |
void setZangle(RealType angle, int snapshotNo) { |
765 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle; |
766 |
|
} |
767 |
|
|
770 |
|
* @param angle new z-angle |
771 |
|
* @see #getZangle |
772 |
|
*/ |
773 |
< |
void addPrevZangle(double angle) { |
773 |
> |
void addPrevZangle(RealType angle) { |
774 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle; |
775 |
|
} |
776 |
|
|
778 |
|
* Adds z-angle into the current z-angle of this stuntdouble |
779 |
|
* @param angle new z-angle |
780 |
|
*/ |
781 |
< |
void addZangle(double angle) { |
781 |
> |
void addZangle(RealType angle) { |
782 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle; |
783 |
|
} |
784 |
|
|
788 |
|
* @param snapshotNo |
789 |
|
* @see #getZangle |
790 |
|
*/ |
791 |
< |
void addZangle(double angle, int snapshotNo) { |
791 |
> |
void addZangle(RealType angle, int snapshotNo) { |
792 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle; |
793 |
|
} |
794 |
|
|
804 |
|
* Returns the gradient of this stuntdouble |
805 |
|
* @return the gradient of this stuntdouble |
806 |
|
*/ |
807 |
< |
virtual std::vector<double> getGrad() = 0; |
807 |
> |
virtual std::vector<RealType> getGrad() = 0; |
808 |
|
|
809 |
|
/** |
810 |
|
* Tests the if this stuntdouble is a linear rigidbody |
830 |
|
} |
831 |
|
|
832 |
|
/** Returns the mass of this stuntdouble */ |
833 |
< |
double getMass() { |
833 |
> |
RealType getMass() { |
834 |
|
return mass_; |
835 |
|
} |
836 |
|
|
838 |
|
* Sets the mass of this stuntdoulbe |
839 |
|
* @param mass the mass to be set |
840 |
|
*/ |
841 |
< |
void setMass(double mass) { |
841 |
> |
void setMass(RealType mass) { |
842 |
|
mass_ = mass; |
843 |
|
} |
844 |
|
|
845 |
|
/** Returns the name of this stuntdouble */ |
846 |
|
virtual std::string getType() = 0; |
847 |
|
|
848 |
< |
/** Sets the name of this stuntdouble*/ |
848 |
> |
/** Sets the name of this stuntRealType*/ |
849 |
|
virtual void setType(const std::string& name) {} |
850 |
|
|
851 |
|
/** |
939 |
|
|
940 |
|
|
941 |
|
int globalIndex_; |
942 |
+ |
int globalIntegrableObjectIndex_; |
943 |
|
int localIndex_; |
944 |
|
|
945 |
|
|
946 |
< |
double mass_; |
946 |
> |
RealType mass_; |
947 |
|
|
948 |
|
private: |
949 |
|
|