Aufgabe 2.2 - Vector2D constructor
This commit is contained in:
parent
78159521c7
commit
010cb5853a
@ -32,6 +32,18 @@ public class Vector2D implements IVector2D {
|
|||||||
this.dy = dy;
|
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
|
* Getter for the dx-part
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user