springForce
Canonical ID: physics.springForce. Nederlands: veerKracht.
Signature
springForce(displacement, velocity, stiffness, damping)
Returns the signed restoring force -stiffness * displacement - damping * velocity
along your chosen axis. Displacement and velocity may be positive or negative;
stiffness must be positive and damping nonnegative. All values and the computed
force must be finite. The function does not move a body or advance a clock.
Example
# language: en
let force = springForce(0.5, 2, 120, 0.35)
say force # -60.7 N: upward if your axis points downward
For a trampoline, calculate compression during contact, apply this force to your character’s velocity, and record the same state in Labs. See the bundled Trampoline Lab example. The spring never pulls a character downward if your contact rule clamps tensile force to zero.