FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CLinearSpring.h
1
4//
9
10#ifndef CLINEARSPRING_H
11#define CLINEARSPRING_H
12
13#include "sfh/timers/Timer.h"
14
15#include <fhsim/simobject/SimObject.h>
16#include <limits>
17#include <string>
18
19#ifdef FH_VISUALIZATION
20# include "sfh/ogre/C3DLine.h"
21#endif
22
23// Class definition
24class CLinearSpring : public SimObject
25{
26public:
28 CLinearSpring(std::string sSimObjectName, ISimObjectCreator* pCreator);
29
32
33#ifdef FH_VISUALIZATION
35 virtual void RenderInit(Ogre::Root* const pOgreRoot, ISimObjectCreator* const pCreator);
36
38 virtual void RenderUpdate(const double dT, const double* const adX);
39#endif
40
41 // Member functions
43 void OdeFcn(const double dT, const double* const adX, double* const adXDot) const { }
44
46 const double* ForceA(const double dT, const double* const adX);
47
49 const double* ForceB(const double dT, const double* const adX);
50
51protected:
53 void CalcOutput(const double dT, const double* const adX) const;
54
55 // Member variables
56 double m_dStiffness;
58 ISignalPort* m_pInPosA;
59 ISignalPort* m_pInPosB;
60 mutable double m_adOutForceA[3];
61 mutable double m_adOutForceB[3];
62 sfh::timers::Timer m_OutputTimer;
63 ICommonComputation* m_CalcOutputs;
64#ifdef FH_VISUALIZATION
65 Ogre::Entity* m_pRenderEntity;
66 Ogre::SceneNode* m_pRenderNode;
67 int m_iNumPoints;
68 C3DLine* m_pLines;
69#endif
70};
71
72
73#endif
A linear spring in 3 degrees of freedom.
Definition CLinearSpring.h:25
CLinearSpring(std::string sSimObjectName, ISimObjectCreator *pCreator)
The constructor sets the pointer to the output object and the parser object.
const double * ForceA(const double dT, const double *const adX)
Calculates the end force A.
double m_adOutForceB[3]
Force vector on point B.
Definition CLinearSpring.h:61
ICommonComputation * m_CalcOutputs
Common computation for outputs.
Definition CLinearSpring.h:63
ISignalPort * m_pInPosB
Input for position B.
Definition CLinearSpring.h:59
const double * ForceB(const double dT, const double *const adX)
Calculates the end force B.
~CLinearSpring()
The destructor cleans up dynamically allocated memory.
double m_adOutForceA[3]
Force vector on point A.
Definition CLinearSpring.h:60
ISignalPort * m_pInPosA
Input for position A.
Definition CLinearSpring.h:58
double m_dStiffness
The linear stiffness of the spring.
Definition CLinearSpring.h:56
sfh::timers::Timer m_OutputTimer
Output timer.
Definition CLinearSpring.h:62
void CalcOutput(const double dT, const double *const adX) const
< Sets the parameters of the spring.
double m_dRelaxedLength
the relaxed length of the spring.
Definition CLinearSpring.h:57
void OdeFcn(const double dT, const double *const adX, double *const adXDot) const
Does nothing, as the object contains no states.
Definition CLinearSpring.h:43