vector getSpringForce(position from,position to,float desiredLength,float constant) { vector force=new vector(from,to); if(dist(from,to)!=0) { position targetPos=new position(to.displace(force.a+180,desiredLength)); vector deltaLength=new vector(from,targetPos); // fill(255,0,0); // ellipse(targetPos.x,targetPos.y,5,5); force=new vector(deltaLength); force.m*=constant; } return force; } float getSpringForceScalar(float from,float to,float desiredLength,float constant) { float force=to; force-=from; if(force!=0) { float deltaLength=force; float targetLength=desiredLength; deltaLength=deltaLength-targetLength; force=deltaLength; force*=constant; } return force; }