public double getForce(SpringAttachable ball) {
      double force = 0;
      if ((a_end == null) || (b_end == null))
         return force;
      if ((ball != a_end) && (ball != b_end))
         return force;
      double a_pos = getAendPosition();
      double b_pos = getBendPosition();
      stretch = Math.abs(b_pos-a_pos)-restLength;
      force = stretch*stiffness;
      if ((ball==a_end)^(a_pos<b_pos)) return -force;
      return force;
   }