AnimatLab  2
Test
Spring.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 namespace AnimatSim
10 {
11  namespace Environment
12  {
13  namespace Bodies
14  {
15 
25  class ANIMAT_PORT Spring : public LineBase
26  {
27  protected:
30 
33 
36 
39 
42 
44  float m_fltDamping;
45 
48 
51 
53  float m_fltTension;
54 
56  float m_fltEnergy;
57 
60 
63 
65  CStdCircularArray<float> m_aryVelocityAvg;
66 
67  //Tension derived only from the stifness portion of the equation.
68  float m_fltStiffnessTension;
69 
70  //Tension derived only from the damping portion of the equation.
71  float m_fltDampingTension;
72 
79  virtual void CalculateTension();
80 
87  virtual void ClearVelocityAverage();
88 
89  public:
90  Spring();
91  virtual ~Spring();
92 
93  static Spring *CastToDerived(AnimatBase *lpBase) {return static_cast<Spring*>(lpBase);}
94 
95  virtual bool InitEnabled();
96 
105  virtual float NaturalLength();
106 
116  virtual void NaturalLength(float fltVal, bool bUseScaling = true);
117 
126  virtual float Stiffness();
127 
137  virtual void Stiffness(float fltVal, bool bUseScaling = true);
138 
147  virtual float Damping();
148 
158  virtual void Damping(float fltVal, bool bUseScaling = true);
159 
160  virtual float Displacement();
161  virtual float Tension();
162  virtual float Energy();
163  virtual float Velocity();
164 
165  virtual void ResetSimulation();
166  virtual void CreateParts();
167  virtual float *GetDataPointer(const std::string &strDataType);
168  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
169  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
170  virtual void AddExternalNodeInput(int iTargetDataType, float fltInput);
171  virtual void Load(CStdXml &oXml);
172  };
173 
174  } //Joints
175  } // Environment
176 } //AnimatSim
float m_fltStiffness
The stiffness of the spring.
Definition: Spring.h:38
float m_fltNaturalLength
The natural length of the spring.
Definition: Spring.h:32
Root namespace for the base simulation library for AnimatLab.
float m_fltDamping
The damping of the spring.
Definition: Spring.h:44
float m_fltVelocity
The velocity of the spring length change.
Definition: Spring.h:59
float m_fltAvgVelocity
The rolling average velocity over the last 5 steps.
Definition: Spring.h:62
Spring body part type.
Definition: Spring.h:25
bool m_bInitEnabled
Keeps track of the initial state of the enabled flag.
Definition: Spring.h:29
float m_fltDampingNotScaled
The damping of the spring.
Definition: Spring.h:47
Animat base class.
Definition: AnimatBase.h:36
float m_fltEnergy
The current energy contained in the spring.
Definition: Spring.h:56
float m_fltStiffnessNotScaled
The unscaled stiffness. This is used to calcuate the energy.
Definition: Spring.h:41
float m_fltDisplacement
The current displacement of the spring from its natural length.
Definition: Spring.h:50
Base class for Line body part types.
Definition: LineBase.h:25
float m_fltNaturalLengthNotScaled
The unscaled natural length. This is used to calcuate the tension and displacement.
Definition: Spring.h:35
CStdCircularArray< float > m_aryVelocityAvg
circular array for calculating the rolling average of the velocity.
Definition: Spring.h:65
float m_fltTension
The current force being applied by the spring.
Definition: Spring.h:53