@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
10 lines (9 loc) • 393 B
JavaScript
/**
* Spring force calculation
* @param {number} displacement how far the spring is being stretched from its resting state
* @param {number} stiffness how still is the spring
* @return {number} force in the direction of displacement exerted by the spring trying to pull back
*/
export function computeHookeForce(displacement, stiffness) {
return -stiffness * displacement;
}