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; }
public void transformVector(Vector v) { double tempX = (this.r11*v.x()) + (this.r21 * v.y()) + (this.r31); double tempY = (this.r12*v.x()) + (this.r22 * v.y()) + (this.r32); v.setVectorValues(tempX,tempY); }