/* this method returns the difference of this vector and its parameter. */ public Vector2D subtract(Vector2D d2) { double a = x - d2.x; double b = y - d2.y; return (new Vector2D(a, b)); }
/* this method returns the sum of this vector and its parameter. */ public Vector2D add(Vector2D d2) { double a = x + d2.x; double b = y + d2.y; return (new Vector2D(a, b)); }
/* this method returns the dot product of this vector and its parameter. */ public double dotProduct(Vector2D d2) { return (x * d2.x + y * d2.y); }