| 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) { |
| 165 |
|
*/ |
| 166 |
|
bool isDirectional(){ |
| 167 |
|
return isDirectionalAtom() || isRigidBody(); |
| 168 |
+ |
} |
| 169 |
+ |
|
| 170 |
+ |
/** |
| 171 |
+ |
* Freezes out all velocity, angular velocity, forces and torques |
| 172 |
+ |
* on this StuntDouble. Also computes the number of frozen degrees |
| 173 |
+ |
* of freedom. |
| 174 |
+ |
* @return the total number of frozen degrees of freedom |
| 175 |
+ |
*/ |
| 176 |
+ |
int freeze() { |
| 177 |
+ |
|
| 178 |
+ |
int fdf = 3; |
| 179 |
+ |
|
| 180 |
+ |
setVel(V3Zero); |
| 181 |
+ |
setFrc(V3Zero); |
| 182 |
+ |
if (isDirectional()){ |
| 183 |
+ |
setJ(V3Zero); |
| 184 |
+ |
setTrq(V3Zero); |
| 185 |
+ |
if (isLinear()) |
| 186 |
+ |
fdf +=2; |
| 187 |
+ |
else |
| 188 |
+ |
fdf +=3; |
| 189 |
+ |
} |
| 190 |
+ |
return fdf; |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
/** |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
/** |
| 486 |
< |
* Sets the previous euler angles of this stuntdouble. |
| 486 |
> |
* Sets the previous euler angles of this stuntRealType. |
| 487 |
|
* @param euler new euler angles |
| 488 |
|
* @see #getEuler |
| 489 |
|
* @note actual storage data is rotation matrix |
| 710 |
|
* Returns the previous z-angle of this stuntdouble |
| 711 |
|
* @return the z-angle of this stuntdouble |
| 712 |
|
*/ |
| 713 |
< |
double getPrevZangle() { |
| 713 |
> |
RealType getPrevZangle() { |
| 714 |
|
return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_]; |
| 715 |
|
} |
| 716 |
|
|
| 718 |
|
* Returns the current z-angle of this stuntdouble |
| 719 |
|
* @return the z-angle of this stuntdouble |
| 720 |
|
*/ |
| 721 |
< |
double getZangle() { |
| 721 |
> |
RealType getZangle() { |
| 722 |
|
return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_]; |
| 723 |
|
} |
| 724 |
|
|
| 727 |
|
* @return the z-angle of this stuntdouble |
| 728 |
|
* @param snapshotNo |
| 729 |
|
*/ |
| 730 |
< |
double getZangle(int snapshotNo) { |
| 730 |
> |
RealType getZangle(int snapshotNo) { |
| 731 |
|
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_]; |
| 732 |
|
} |
| 733 |
|
|
| 736 |
|
* @param angle new z-angle |
| 737 |
|
* @see #getZangle |
| 738 |
|
*/ |
| 739 |
< |
void setPrevZangle(double angle) { |
| 739 |
> |
void setPrevZangle(RealType angle) { |
| 740 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle; |
| 741 |
|
} |
| 742 |
|
|
| 744 |
|
* Sets the current z-angle of this stuntdouble |
| 745 |
|
* @param angle new z-angle |
| 746 |
|
*/ |
| 747 |
< |
void setZangle(double angle) { |
| 747 |
> |
void setZangle(RealType angle) { |
| 748 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle; |
| 749 |
|
} |
| 750 |
|
|
| 754 |
|
* @param snapshotNo |
| 755 |
|
* @see #getZangle |
| 756 |
|
*/ |
| 757 |
< |
void setZangle(double angle, int snapshotNo) { |
| 757 |
> |
void setZangle(RealType angle, int snapshotNo) { |
| 758 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle; |
| 759 |
|
} |
| 760 |
|
|
| 763 |
|
* @param angle new z-angle |
| 764 |
|
* @see #getZangle |
| 765 |
|
*/ |
| 766 |
< |
void addPrevZangle(double angle) { |
| 766 |
> |
void addPrevZangle(RealType angle) { |
| 767 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle; |
| 768 |
|
} |
| 769 |
|
|
| 771 |
|
* Adds z-angle into the current z-angle of this stuntdouble |
| 772 |
|
* @param angle new z-angle |
| 773 |
|
*/ |
| 774 |
< |
void addZangle(double angle) { |
| 774 |
> |
void addZangle(RealType angle) { |
| 775 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle; |
| 776 |
|
} |
| 777 |
|
|
| 781 |
|
* @param snapshotNo |
| 782 |
|
* @see #getZangle |
| 783 |
|
*/ |
| 784 |
< |
void addZangle(double angle, int snapshotNo) { |
| 784 |
> |
void addZangle(RealType angle, int snapshotNo) { |
| 785 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle; |
| 786 |
|
} |
| 787 |
|
|
| 797 |
|
* Returns the gradient of this stuntdouble |
| 798 |
|
* @return the gradient of this stuntdouble |
| 799 |
|
*/ |
| 800 |
< |
virtual std::vector<double> getGrad() = 0; |
| 800 |
> |
virtual std::vector<RealType> getGrad() = 0; |
| 801 |
|
|
| 802 |
|
/** |
| 803 |
|
* Tests the if this stuntdouble is a linear rigidbody |
| 823 |
|
} |
| 824 |
|
|
| 825 |
|
/** Returns the mass of this stuntdouble */ |
| 826 |
< |
double getMass() { |
| 826 |
> |
RealType getMass() { |
| 827 |
|
return mass_; |
| 828 |
|
} |
| 829 |
|
|
| 831 |
|
* Sets the mass of this stuntdoulbe |
| 832 |
|
* @param mass the mass to be set |
| 833 |
|
*/ |
| 834 |
< |
void setMass(double mass) { |
| 834 |
> |
void setMass(RealType mass) { |
| 835 |
|
mass_ = mass; |
| 836 |
|
} |
| 837 |
|
|
| 838 |
|
/** Returns the name of this stuntdouble */ |
| 839 |
|
virtual std::string getType() = 0; |
| 840 |
|
|
| 841 |
< |
/** Sets the name of this stuntdouble*/ |
| 841 |
> |
/** Sets the name of this stuntRealType*/ |
| 842 |
|
virtual void setType(const std::string& name) {} |
| 843 |
|
|
| 844 |
|
/** |
| 935 |
|
int localIndex_; |
| 936 |
|
|
| 937 |
|
|
| 938 |
< |
double mass_; |
| 938 |
> |
RealType mass_; |
| 939 |
|
|
| 940 |
|
private: |
| 941 |
|
|