I'm trying to add springs to my physics engine, and while the algorithm itself works, they are incredibly stiff ( have to feed in values <= about 0.1 to get any visible motion out of it, and it has to be set extremely small in order to work properly). Any tips for improving the following code so it's not as stiff with values in the 0.1 to 1 range?
Vector2 posDiff = _a1.Position - _a2.Position;
Vector2 diffNormal = posDiff;
diffNormal.Normalize();
Vector2 relativeVelocity = _a1.Velocity - _a2.Velocity;
float diffLength = posDiff.Length();
float springError = diffLength - _restLength;
float springStrength = springError * _springStrength;
if (!float.IsPositiveInfinity(_breakpoint) && (springError > _breakpoint || springError < -1 * _breakpoint))
{
_isBroken = true;
}
float temp = Vector2.Dot(posDiff, relativeVelocity);
float dampening = _springDampening * temp / diffLength;
Vector2 _force = Vector2.Multiply(diffNormal, -(springStrength + dampening));
_a1.ApplyForce(_force / 2);
_a2.ApplyForce(-_force / 2);