Public Member Functions | Private Attributes | List of all members
SurgSim::Physics::LinearSpring Class Reference

Linear spring connecting 2 nodes with a viscous term. More...

#include <SurgSim/Physics/LinearSpring.h>

Inheritance diagram for SurgSim::Physics::LinearSpring:
SurgSim::Physics::Spring

Public Member Functions

 LinearSpring (size_t nodeId0, size_t nodeId1)
 Constructor. More...
 
void setStiffness (double stiffness)
 Sets the spring stiffness parameter. More...
 
double getStiffness () const
 Gets the spring stiffness parameter. More...
 
void setDamping (double damping)
 Sets the spring damping parameter. More...
 
double getDamping () const
 Gets the spring damping parameter. More...
 
void setRestLength (double restLength)
 Sets the rest length of the spring. More...
 
double getRestLength () const
 Gets the rest length of the spring. More...
 
virtual void addForce (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, double scale=1.0) override
 Adds the spring force (computed for a given state) to a complete system force vector F (assembly) More...
 
virtual void addDamping (const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *D, double scale=1.0) override
 Adds the spring damping matrix D (= -df/dv) (computed for a given state) to a complete system damping matrix D (assembly) More...
 
virtual void addStiffness (const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *K, double scale=1.0) override
 Adds the spring stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly) More...
 
virtual void addFDK (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, SurgSim::Math::Matrix *D, SurgSim::Math::Matrix *K) override
 Adds the spring force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, D, K (assembly) More...
 
virtual void addMatVec (const SurgSim::Math::OdeState &state, double alphaD, double alphaK, const SurgSim::Math::Vector &vector, SurgSim::Math::Vector *F) override
 Adds the spring matrix-vector contribution F += (alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly) More...
 
bool operator== (const Spring &spring) const
 Comparison operator (equality) More...
 
bool operator!= (const Spring &spring) const
 Comparison operator (inequality) More...
 
- Public Member Functions inherited from SurgSim::Physics::Spring
virtual ~Spring ()
 Virtual destructor. More...
 
size_t getNumNodes () const
 Gets the number of nodes the spring is connecting. More...
 
size_t getNodeId (size_t springNodeId) const
 Gets the springNodeId-th node id. More...
 
const std::vector< size_t > & getNodeIds () const
 Gets the node ids for this spring. More...
 

Private Attributes

double m_restLength
 Rest length (in m) More...
 
double m_stiffness
 Stiffness parameters (in N.m-1) More...
 
double m_damping
 Damping parameters (in N.s.m-1) More...
 

Additional Inherited Members

- Protected Attributes inherited from SurgSim::Physics::Spring
std::vector< size_t > m_nodeIds
 Node ids connected by this spring. More...
 

Detailed Description

Linear spring connecting 2 nodes with a viscous term.

Constructor & Destructor Documentation

SurgSim::Physics::LinearSpring::LinearSpring ( size_t  nodeId0,
size_t  nodeId1 
)

Constructor.

Parameters
nodeId0,nodeId1The node ids on which the spring is attached

Member Function Documentation

void SurgSim::Physics::LinearSpring::addDamping ( const SurgSim::Math::OdeState state,
SurgSim::Math::Matrix D,
double  scale = 1.0 
)
overridevirtual

Adds the spring damping matrix D (= -df/dv) (computed for a given state) to a complete system damping matrix D (assembly)

Parameters
stateThe state to compute the damping matrix with
[in,out]DThe complete system damping matrix to add the spring damping matrix into
scaleA factor to scale the added damping matrix with

Implements SurgSim::Physics::Spring.

void SurgSim::Physics::LinearSpring::addFDK ( const SurgSim::Math::OdeState state,
SurgSim::Math::Vector F,
SurgSim::Math::Matrix D,
SurgSim::Math::Matrix K 
)
overridevirtual

Adds the spring force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, D, K (assembly)

Parameters
stateThe state to compute everything with
[in,out]FThe complete system force vector to add the spring force into
[in,out]DThe complete system damping matrix to add the spring damping matrix into
[in,out]KThe complete system stiffness matrix to add the spring stiffness matrix into

Implements SurgSim::Physics::Spring.

void SurgSim::Physics::LinearSpring::addForce ( const SurgSim::Math::OdeState state,
SurgSim::Math::Vector F,
double  scale = 1.0 
)
overridevirtual

Adds the spring force (computed for a given state) to a complete system force vector F (assembly)

Parameters
stateThe state to compute the force with
[in,out]FThe complete system force vector to add the spring force into
scaleA factor to scale the added force with

Implements SurgSim::Physics::Spring.

void SurgSim::Physics::LinearSpring::addMatVec ( const SurgSim::Math::OdeState state,
double  alphaD,
double  alphaK,
const SurgSim::Math::Vector vector,
SurgSim::Math::Vector F 
)
overridevirtual

Adds the spring matrix-vector contribution F += (alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly)

Parameters
stateThe state to compute everything with
alphaDThe scaling factor for the damping contribution
alphaKThe scaling factor for the stiffness contribution
vectorA complete system vector to use as the vector in the matrix-vector multiplication
[in,out]FThe complete system force vector to add the element matrix-vector contribution into

Implements SurgSim::Physics::Spring.

void SurgSim::Physics::LinearSpring::addStiffness ( const SurgSim::Math::OdeState state,
SurgSim::Math::Matrix K,
double  scale = 1.0 
)
overridevirtual

Adds the spring stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly)

Parameters
stateThe state to compute the stiffness matrix with
[in,out]KThe complete system stiffness matrix to add the spring stiffness matrix into
scaleA factor to scale the added stiffness matrix with

Implements SurgSim::Physics::Spring.

double SurgSim::Physics::LinearSpring::getDamping ( ) const

Gets the spring damping parameter.

Returns
The damping assigned to the spring (in N.s.m-1)
double SurgSim::Physics::LinearSpring::getRestLength ( ) const

Gets the rest length of the spring.

Returns
The rest length assigned to the spring (in m)
double SurgSim::Physics::LinearSpring::getStiffness ( ) const

Gets the spring stiffness parameter.

Returns
The stiffness assigned to the spring (in N.m-1)
bool SurgSim::Physics::LinearSpring::operator!= ( const Spring spring) const

Comparison operator (inequality)

Parameters
springSpring to compare it to
Returns
False if the 2 springs contains the same information, true otherwise
Note
Comparison is based on spring type, rest length, stiffness and damping coefficients ONLY
bool SurgSim::Physics::LinearSpring::operator== ( const Spring spring) const

Comparison operator (equality)

Parameters
springSpring to compare it to
Returns
True if the 2 springs contains the same information, false otherwise
Note
Comparison is based on spring type, rest length, stiffness and damping coefficients ONLY
void SurgSim::Physics::LinearSpring::setDamping ( double  damping)

Sets the spring damping parameter.

Parameters
dampingThe damping to assign to the spring (in N.s.m-1)
void SurgSim::Physics::LinearSpring::setRestLength ( double  restLength)

Sets the rest length of the spring.

Parameters
restLengthThe rest length to assign to the spring (in m)
void SurgSim::Physics::LinearSpring::setStiffness ( double  stiffness)

Sets the spring stiffness parameter.

Parameters
stiffnessThe stiffness to assign to the spring (in N.m-1)

Member Data Documentation

double SurgSim::Physics::LinearSpring::m_damping
private

Damping parameters (in N.s.m-1)

double SurgSim::Physics::LinearSpring::m_restLength
private

Rest length (in m)

double SurgSim::Physics::LinearSpring::m_stiffness
private

Stiffness parameters (in N.m-1)


The documentation for this class was generated from the following files: