LibCapy - springmass

SpringMass class.

Macros:

Enumerations:

None.

Typedefs:

None.

Struct CapySpringMassNode :

Struct CapySpringMassNode's properties:

Mass id

Mass of the node

Node position

Node velocity

Node acceleration

Fixed mass (true: position stays constant)

User data

Struct CapySpringMassNode's methods:

None.

Struct CapySpringMassLink :

Struct CapySpringMassLink's properties:

Spring coefficients ([0]: in compression regime, [1]: in extension regime)

Length at rest

Links to the masses

User data

Struct CapySpringMassLink's methods:

None.

Struct CapySpringMassDeriv :

Struct CapySpringMassDeriv's properties:

Inherit CapyMathFun

Acceleration force

Struct CapySpringMassDeriv's methods:

Destructor

Struct CapySpringMass :

Struct CapySpringMass's properties:

Space dimension

Dampening coefficient (default: 1.0, in [0.0, 1.0], the lower the stronger the dampening, 1.0 is no dampening)

Graph of the spring-mass sytem

Derivative function

Runge-Kutta instance

Nb max step when searching for stability (default: 1000)

Epsilon value used to check stability (default: 1e-6)

Struct CapySpringMass's methods:

Destructor

Add one mass

Input argument(s):

id: id of the mass

Output and side effect(s):

If no mass with the given id already exists a new one is added. The mass id is the id of the node in the graph. Return the mass. If created the new mass is initialised with a mass of 1.0 and all other params to 0.0.

Get a mass given its id

Input argument(s):

id: the id

Output and side effect(s):

Return the mass, or NULL if there is no mass with the requested id

Add one spring

Input argument(s):

idA: id of the first mass
idB: id of the second mass

Output and side effect(s):

Add a new spring, initialised with spring coefficients of 1.0 and rest length of 1.0. Return the new spring. If there is no mass with the given id they are automatically created.

Get a spring given its masses id

Input argument(s):

idA: the first mass id
idB: the second mass id

Output and side effect(s):

Return the spring, or NULL if there is no spring with the requested ids

Step the spring mass system

Input argument(s):

deltaT: size of the step

Output and side effect(s):

The mass properties are updated.

Step the spring mass system until it stabilizes

Input argument(s):

deltaT: size of the step

Output and side effect(s):

The mass properties are updated.

Get the stress of the system

Output and side effect(s):

Return the total of difference between rest length and actual length of all links

Get the stress of a link

Input argument(s):

idA: the first mass id
idB: the second mass id

Output and side effect(s):

Return the difference between rest length and actual length

Get the current length of a link

Input argument(s):

idA: the first mass id
idB: the second mass id

Output and side effect(s):

Return the current length of the link

Functions:

Create a CapySpringMass

Input argument(s):

dim: space dimension

Output and side effect(s):

Return a CapySpringMass

Allocate memory for a new CapySpringMass and create it

Input argument(s):

dim: space dimension

Output and side effect(s):

Return a CapySpringMass

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapySpringMass* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapySpringMass to free

2025-08-05
in LibCapy,
0 views
Copyright 2021-2025 Baillehache Pascal