Class Vector2D
java.lang.Object
edu.ntnu.stud.chaosgame.model.data.Vector2D
- Direct Known Subclasses:
Complex
Class representing a 2D vector.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
x0
private final double x0The x0 component of the vector. -
x1
private final double x1The x1 component of the vector.
-
-
Constructor Details
-
Vector2D
public Vector2D(double x0, double x1) Create a new 2D vector; parameterized.- Parameters:
x0
- The x0 component of the vector.x1
- The x1 component of the vector.
-
-
Method Details
-
getX0
public double getX0()Get the x0 component of the vector.- Returns:
- The x0 component of the vector.
-
getX1
public double getX1()Get the x1 component of the vector.- Returns:
- The x1 component of the vector.
-
add
Add another vector to this vector.- Parameters:
other
- The other vector to add.- Returns:
- A new vector that is the sum of this vector and the other vector.
-
subtract
Subtract another vector from this vector.- Parameters:
other
- The other vector to subtract.- Returns:
- A new vector that is the difference between this vector and the other vector.
-