diff --git a/src/break_out/model/Vector2D.java b/src/break_out/model/Vector2D.java index cf21599..2ec28b5 100644 --- a/src/break_out/model/Vector2D.java +++ b/src/break_out/model/Vector2D.java @@ -32,6 +32,18 @@ public class Vector2D implements IVector2D { this.dy = dy; } + /** + * This constructor creates a new vector based on the given positions start and end. + * + * @param start first position + * @param end second position + */ + public Vector2D(Position start, Position end) { + // vector(AB) = (B.x - A.x, B.y - A.y) + this.dx = end.getX() - start.getX(); + this.dy = end.getY() - start.getY(); + } + /** * Getter for the dx-part *