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 |
|
*/ |
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 |
+ |
/** |
201 |
|
* Returns the previous position of this stuntdouble |
202 |
|
* @return the position of this stuntdouble |
203 |
|
*/ |
409 |
|
void setJ(const Vector3d& angMom, int snapshotNo) { |
410 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom; |
411 |
|
} |
412 |
< |
|
412 |
> |
|
413 |
> |
/** |
414 |
> |
* Returns system Center of Mass for stuntdouble frame from snapshot |
415 |
> |
* |
416 |
> |
*/ |
417 |
> |
Vector3d getCOM(){ |
418 |
> |
return (snapshotMan_->getCurrentSnapshot())->getCOM(); |
419 |
> |
} |
420 |
> |
|
421 |
> |
/** |
422 |
> |
* Returns system Center of Mass velocity for stuntdouble frame from snapshot |
423 |
> |
* |
424 |
> |
*/ |
425 |
> |
|
426 |
> |
Vector3d getCOMvel(){ |
427 |
> |
return (snapshotMan_->getCurrentSnapshot())->getCOMvel(); |
428 |
> |
} |
429 |
> |
|
430 |
> |
/** |
431 |
> |
* Returns system Center of Mass angular momentum for stuntdouble frame from snapshot |
432 |
> |
* |
433 |
> |
*/ |
434 |
> |
Vector3d getCOMw(){ |
435 |
> |
return (snapshotMan_->getCurrentSnapshot())->getCOMw(); |
436 |
> |
} |
437 |
> |
|
438 |
> |
/** |
439 |
> |
* Returns system Center of Mass for stuntdouble frame from snapshot |
440 |
> |
* |
441 |
> |
*/ |
442 |
> |
Vector3d getCOM(int snapshotNo){ |
443 |
> |
return (snapshotMan_->getSnapshot(snapshotNo))->getCOM(); |
444 |
> |
} |
445 |
> |
|
446 |
> |
/** |
447 |
> |
* Returns system Center of Mass velocity for stuntdouble frame from snapshot |
448 |
> |
* |
449 |
> |
*/ |
450 |
> |
|
451 |
> |
Vector3d getCOMvel(int snapshotNo){ |
452 |
> |
return (snapshotMan_->getSnapshot(snapshotNo))->getCOMvel(); |
453 |
> |
} |
454 |
> |
|
455 |
> |
/** |
456 |
> |
* Returns system Center of Mass angular momentum for stuntdouble frame from snapshot |
457 |
> |
* |
458 |
> |
*/ |
459 |
> |
Vector3d getCOMw(int snapshotNo){ |
460 |
> |
return (snapshotMan_->getSnapshot(snapshotNo))->getCOMw(); |
461 |
> |
} |
462 |
> |
|
463 |
|
/** |
464 |
|
* Returns the previous quaternion of this stuntdouble |
465 |
|
* @return the quaternion of this stuntdouble |
540 |
|
} |
541 |
|
|
542 |
|
/** |
543 |
< |
* Sets the previous euler angles of this stuntdouble. |
543 |
> |
* Sets the previous euler angles of this stuntRealType. |
544 |
|
* @param euler new euler angles |
545 |
|
* @see #getEuler |
546 |
|
* @note actual storage data is rotation matrix |
767 |
|
* Returns the previous z-angle of this stuntdouble |
768 |
|
* @return the z-angle of this stuntdouble |
769 |
|
*/ |
770 |
< |
double getPrevZangle() { |
770 |
> |
RealType getPrevZangle() { |
771 |
|
return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_]; |
772 |
|
} |
773 |
|
|
775 |
|
* Returns the current z-angle of this stuntdouble |
776 |
|
* @return the z-angle of this stuntdouble |
777 |
|
*/ |
778 |
< |
double getZangle() { |
778 |
> |
RealType getZangle() { |
779 |
|
return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_]; |
780 |
|
} |
781 |
|
|
784 |
|
* @return the z-angle of this stuntdouble |
785 |
|
* @param snapshotNo |
786 |
|
*/ |
787 |
< |
double getZangle(int snapshotNo) { |
787 |
> |
RealType getZangle(int snapshotNo) { |
788 |
|
return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_]; |
789 |
|
} |
790 |
|
|
793 |
|
* @param angle new z-angle |
794 |
|
* @see #getZangle |
795 |
|
*/ |
796 |
< |
void setPrevZangle(double angle) { |
796 |
> |
void setPrevZangle(RealType angle) { |
797 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle; |
798 |
|
} |
799 |
|
|
801 |
|
* Sets the current z-angle of this stuntdouble |
802 |
|
* @param angle new z-angle |
803 |
|
*/ |
804 |
< |
void setZangle(double angle) { |
804 |
> |
void setZangle(RealType angle) { |
805 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle; |
806 |
|
} |
807 |
|
|
811 |
|
* @param snapshotNo |
812 |
|
* @see #getZangle |
813 |
|
*/ |
814 |
< |
void setZangle(double angle, int snapshotNo) { |
814 |
> |
void setZangle(RealType angle, int snapshotNo) { |
815 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle; |
816 |
|
} |
817 |
|
|
820 |
|
* @param angle new z-angle |
821 |
|
* @see #getZangle |
822 |
|
*/ |
823 |
< |
void addPrevZangle(double angle) { |
823 |
> |
void addPrevZangle(RealType angle) { |
824 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle; |
825 |
|
} |
826 |
|
|
828 |
|
* Adds z-angle into the current z-angle of this stuntdouble |
829 |
|
* @param angle new z-angle |
830 |
|
*/ |
831 |
< |
void addZangle(double angle) { |
831 |
> |
void addZangle(RealType angle) { |
832 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle; |
833 |
|
} |
834 |
|
|
838 |
|
* @param snapshotNo |
839 |
|
* @see #getZangle |
840 |
|
*/ |
841 |
< |
void addZangle(double angle, int snapshotNo) { |
841 |
> |
void addZangle(RealType angle, int snapshotNo) { |
842 |
|
((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle; |
843 |
|
} |
844 |
|
|
854 |
|
* Returns the gradient of this stuntdouble |
855 |
|
* @return the gradient of this stuntdouble |
856 |
|
*/ |
857 |
< |
virtual std::vector<double> getGrad() = 0; |
857 |
> |
virtual std::vector<RealType> getGrad() = 0; |
858 |
|
|
859 |
|
/** |
860 |
|
* Tests the if this stuntdouble is a linear rigidbody |
880 |
|
} |
881 |
|
|
882 |
|
/** Returns the mass of this stuntdouble */ |
883 |
< |
double getMass() { |
883 |
> |
RealType getMass() { |
884 |
|
return mass_; |
885 |
|
} |
886 |
|
|
888 |
|
* Sets the mass of this stuntdoulbe |
889 |
|
* @param mass the mass to be set |
890 |
|
*/ |
891 |
< |
void setMass(double mass) { |
891 |
> |
void setMass(RealType mass) { |
892 |
|
mass_ = mass; |
893 |
|
} |
894 |
|
|
895 |
|
/** Returns the name of this stuntdouble */ |
896 |
|
virtual std::string getType() = 0; |
897 |
|
|
898 |
< |
/** Sets the name of this stuntdouble*/ |
898 |
> |
/** Sets the name of this stuntRealType*/ |
899 |
|
virtual void setType(const std::string& name) {} |
900 |
|
|
901 |
|
/** |
989 |
|
|
990 |
|
|
991 |
|
int globalIndex_; |
992 |
+ |
int globalIntegrableObjectIndex_; |
993 |
|
int localIndex_; |
994 |
|
|
995 |
|
|
996 |
< |
double mass_; |
996 |
> |
RealType mass_; |
997 |
|
|
998 |
|
private: |
999 |
|
|