-
Notifications
You must be signed in to change notification settings - Fork 2
Spring Force
jsutlive edited this page Oct 25, 2022
·
8 revisions
Abstract class
extends Force
implements N/A
Spring Force is a component which inherits from Force and applies a spring force to a group of edges assigned to it.
| Accessibility | Type | Field Name | Description |
|---|---|---|---|
| public | float | constant | spring constant |
| public | float | targetLengthRatio | ratio which represent the resting length of the target divided by its original length |
| Accessibility | Return Type | Method Name | Description |
|---|---|---|---|
| public | void | setConstant | sets the value for constant |
| public | void | setTargetLengthRatio | sets the value for targetLengthRatio |
| public | Vector | calculateSpringForce | calculates spring force vector derived from calculation of Hooke's law |
The spring equation can be denoted as
F = -k(l - l0)
Where F is the force applied by the spring, k is the spring's stiffness constant, l is the current length of the spring and l0 is the resting length of the spring.
We use the targetLengthRatio to provide a more easily tunable parameter across the model, where l0 may be of different values depending on the position/ location of different nodes/ edges. With r representing tragetLengthRatio and lstart representing the length at the time of the simulation start here, we calculate
*l0 = r (lstart) and therefore,
F = -k(l - r (lstart))