public bool accumForce(Vector startForce, Vector forceToAdd) { double curMag = Math.sqrt(startForce.lengthSquared()); double remaining = owner.maxForce() - curMag; if(remaining <= 0.0)return false; double magAdd = Math.sqrt(forceToAdd.lengthSquared()); if(magAdd < remaining){ startForce.setVectorValues(startForce.x() + forceToAdd.x(), startForce.y() + forceToAdd.y()); }else { Vector temp = new Vector(forceToAdd); temp.normalise(); startForce.setVectorValues(temp.x()*remaining, temp.y()*remaining); } return true; }