1
0
Fork 0

Aufgabe 2.2 - Vector2D constructor

This commit is contained in:
rxbn_ 2019-12-06 19:06:51 +01:00
parent 78159521c7
commit 010cb5853a
1 changed files with 12 additions and 0 deletions

View File

@ -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
*