CellModules
MassSpringDamper< cell_t > Class Template Reference

Class for managing mass-spring-damper physics. More...

#include <MassSpringDamper.hpp>

Public Member Functions

 MassSpringDamper ()=default
 Default constructor. More...
 
 MassSpringDamper (cell_t *c1, cell_t *c2, const float_t &K, const float_t &C, const float_t &L)
 Constructor with parameters. More...
 
void setRestLength (float_t L)
 Sets the rest length of the spring. More...
 
float_t getRestLength () const
 Gets the rest length of the spring. More...
 
float_t getLength () const
 Gets the current length of the spring. More...
 
std::pair< cell_t *, cell_t * > getConnection () const
 Gets the connection between the cells. More...
 
void computeForces ()
 Computes the forces for the connected cells. More...
 
std::string toString ()
 Gets the connection as a string. More...
 

Private Member Functions

void updateLengthDirection (const MecaCell::Vec &p0, const MecaCell::Vec &p1)
 Updates the current length and direction. More...
 
double computeSpeedFromCells ()
 Computes the total speed from the connected cells. More...
 

Private Attributes

std::pair< cell_t *, cell_t * > connection
 
float_t stiffness
 
float_t dampCoef
 
float_t restLength
 
float_t length
 
MecaCell::Vec direction
 

Detailed Description

template<typename cell_t>
class MassSpringDamper< cell_t >

Class for managing mass-spring-damper physics.

Template Parameters
cell_tType of the cell.

Definition at line 21 of file MassSpringDamper.hpp.

Constructor & Destructor Documentation

◆ MassSpringDamper() [1/2]

template<typename cell_t >
MassSpringDamper< cell_t >::MassSpringDamper ( )
inlinedefault

Default constructor.

◆ MassSpringDamper() [2/2]

template<typename cell_t >
MassSpringDamper< cell_t >::MassSpringDamper ( cell_t *  c1,
cell_t *  c2,
const float_t &  K,
const float_t &  C,
const float_t &  L 
)
inline

Constructor with parameters.

Parameters
c1Pointer to the first cell.
c2Pointer to the second cell.
KSpring stiffness.
CDamping coefficient.
LRest length.

Definition at line 69 of file MassSpringDamper.hpp.

Member Function Documentation

◆ computeForces()

template<typename cell_t >
void MassSpringDamper< cell_t >::computeForces ( )
inline

Computes the forces for the connected cells.

Definition at line 103 of file MassSpringDamper.hpp.

◆ computeSpeedFromCells()

template<typename cell_t >
double MassSpringDamper< cell_t >::computeSpeedFromCells ( )
inlineprivate

Computes the total speed from the connected cells.

Returns
The cumulative speed of the cells.

Definition at line 48 of file MassSpringDamper.hpp.

◆ getConnection()

template<typename cell_t >
std::pair< cell_t *, cell_t * > MassSpringDamper< cell_t >::getConnection ( ) const
inline

Gets the connection between the cells.

Returns
Pair of connected cells.

Definition at line 98 of file MassSpringDamper.hpp.

◆ getLength()

template<typename cell_t >
float_t MassSpringDamper< cell_t >::getLength ( ) const
inline

Gets the current length of the spring.

Returns
Current length.

Definition at line 91 of file MassSpringDamper.hpp.

◆ getRestLength()

template<typename cell_t >
float_t MassSpringDamper< cell_t >::getRestLength ( ) const
inline

Gets the rest length of the spring.

Returns
Rest length.

Definition at line 84 of file MassSpringDamper.hpp.

◆ setRestLength()

template<typename cell_t >
void MassSpringDamper< cell_t >::setRestLength ( float_t  L)
inline

Sets the rest length of the spring.

Parameters
LRest length.

Definition at line 77 of file MassSpringDamper.hpp.

◆ toString()

template<typename cell_t >
std::string MassSpringDamper< cell_t >::toString ( )
inline

Gets the connection as a string.

Returns
String representation of the connection.

Definition at line 122 of file MassSpringDamper.hpp.

◆ updateLengthDirection()

template<typename cell_t >
void MassSpringDamper< cell_t >::updateLengthDirection ( const MecaCell::Vec p0,
const MecaCell::Vec p1 
)
inlineprivate

Updates the current length and direction.

Parameters
p0Position of the first cell.
p1Position of the second cell.

Definition at line 37 of file MassSpringDamper.hpp.

Member Data Documentation

◆ connection

template<typename cell_t >
std::pair<cell_t*, cell_t*> MassSpringDamper< cell_t >::connection
private

Pair of cells that are connected

Definition at line 24 of file MassSpringDamper.hpp.

◆ dampCoef

template<typename cell_t >
float_t MassSpringDamper< cell_t >::dampCoef
private

Spring's damping coefficient in ng/s

Definition at line 26 of file MassSpringDamper.hpp.

◆ direction

template<typename cell_t >
MecaCell::Vec MassSpringDamper< cell_t >::direction
private

Spring's current direction from node 0 to 1

Definition at line 29 of file MassSpringDamper.hpp.

◆ length

template<typename cell_t >
float_t MassSpringDamper< cell_t >::length
private

Spring's current length in µm

Definition at line 28 of file MassSpringDamper.hpp.

◆ restLength

template<typename cell_t >
float_t MassSpringDamper< cell_t >::restLength
private

Spring's rest length in µm

Definition at line 27 of file MassSpringDamper.hpp.

◆ stiffness

template<typename cell_t >
float_t MassSpringDamper< cell_t >::stiffness
private

Spring's stiffness in ng/s^2

Definition at line 25 of file MassSpringDamper.hpp.


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