00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __SIM_ConRelSpring_h__
00015 #define __SIM_ConRelSpring_h__
00016
00017 #include "SIM_API.h"
00018 #include "SIM_ConRel.h"
00019 #include "SIM_OptionsUser.h"
00020 #include <UT/UT_Vector3.h>
00021 #include <UT/UT_Matrix3.h>
00022
00023 class SIM_ConAnchorSpatial;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class SIM_API SIM_ConRelSpring : public SIM_ConRel,
00036 public SIM_OptionsUser
00037 {
00038 public:
00039
00040
00041 UT_Vector3 getForce(const SIM_Time &time,
00042 const SIM_ConAnchorSpatial &objAnchor,
00043 const SIM_ConAnchorSpatial &otherAnchor,
00044 UT_Matrix3 *jacobianPos = NULL,
00045 UT_Matrix3 *jacobianVel = NULL);
00046 UT_Vector3 getForce(const UT_Vector3 &objAnchorPos,
00047 const UT_Vector3 &objAnchorVel,
00048 const UT_Vector3 &otherAnchorPos,
00049 const UT_Vector3 &otherAnchorVel,
00050 const UT_Matrix3 &dofFilter);
00051 UT_Vector3 getTorque(const UT_Quaternion &objOrient,
00052 const UT_Vector3 &objAngVel,
00053 const UT_Quaternion &anchorOrient,
00054 const UT_Vector3 &anchorAngVel);
00055
00056
00057
00058 UT_Matrix3 getJacobianPos(const UT_Vector3 &objAnchorPos,
00059 const UT_Vector3 &objAnchorVel,
00060 const UT_Vector3 &otherAnchorPos,
00061 const UT_Vector3 &otherAnchorVel,
00062 const UT_Matrix3 &dofFilter) const;
00063
00064 UT_Matrix3 getJacobianVel(const UT_Vector3 &objAnchorPos,
00065 const UT_Vector3 &objAnchorVel,
00066 const UT_Vector3 &otherAnchorPos,
00067 const UT_Vector3 &otherAnchorVel,
00068 const UT_Matrix3 &dofFilter) const;
00069
00070
00071 GETSET_DATA_FUNCS_F(SIM_NAME_STRENGTH, Strength);
00072
00073 GETSET_DATA_FUNCS_F(SIM_NAME_RESTLENGTH, RestLength);
00074
00075 GETSET_DATA_FUNCS_F(SIM_NAME_DAMPING, Damping);
00076
00077 protected:
00078 explicit SIM_ConRelSpring(const SIM_DataFactory *factory);
00079 virtual ~SIM_ConRelSpring();
00080
00081 virtual void setStateForceSubclass(fpreal force);
00082 virtual fpreal getStateForceSubclass() const;
00083 virtual void setStateDistanceSubclass(fpreal distance);
00084 virtual fpreal getStateDistanceSubclass() const;
00085
00086 virtual void buildConRelGuideSpatial(
00087 const GU_DetailHandle &gdh,
00088 const SIM_Options &options,
00089 const UT_Vector3 &anchorPos1,
00090 const UT_Vector3 &anchorPos2) const;
00091 virtual UT_Vector3 getForceSubclass(const UT_Vector3 &objAnchorPos,
00092 const UT_Vector3 &objAnchorVel,
00093 const UT_Vector3 &otherAnchorPos,
00094 const UT_Vector3 &otherAnchorVel,
00095 const UT_Matrix3 &dofFilter);
00096 virtual UT_Vector3 getTorqueSubclass(const UT_Quaternion &objOrient,
00097 const UT_Vector3 &objAngVel,
00098 const UT_Quaternion &anchorOrient,
00099 const UT_Vector3 &anchorAngVel);
00100 virtual UT_Matrix3 getJacobianPosSubclass(const UT_Vector3 &objAnchorPos,
00101 const UT_Vector3 &objAnchorVel,
00102 const UT_Vector3 &otherAnchorPos,
00103 const UT_Vector3 &otherAnchorVel,
00104 const UT_Matrix3 &dofFilter) const;
00105 virtual UT_Matrix3 getJacobianVelSubclass(const UT_Vector3 &objAnchorPos,
00106 const UT_Vector3 &objAnchorVel,
00107 const UT_Vector3 &otherAnchorPos,
00108 const UT_Vector3 &otherAnchorVel,
00109 const UT_Matrix3 &dofFilter) const;
00110
00111 UT_Vector3 project(const UT_Vector3 &vec,
00112 const UT_Matrix3 &dofFilter) const;
00113
00114 private:
00115 static const SIM_DopDescription *getConRelSpringDopDescription();
00116
00117 fpreal myStateForce;
00118 fpreal myStateDistance;
00119
00120 DECLARE_STANDARD_GETCASTTOTYPE();
00121 DECLARE_DATAFACTORY(SIM_ConRelSpring,
00122 SIM_ConRel,
00123 "Spring Constraint Relationship",
00124 getConRelSpringDopDescription());
00125 };
00126
00127 #endif