public class Vector2D
extends java.lang.Object
| Constructor and Description |
|---|
Vector2D(double x,
double y)
Constructor of the 2D vector class used to create new vector instances.
|
| Modifier and Type | Method and Description |
|---|---|
Vector2D |
add(Vector2D vector)
Adds the given vector to this.
|
double |
cross(Vector2D vector)
Computes the 2D pseudo cross product Dot(Perp(this), vector) of this and
the given vector.
|
double |
dot(Vector2D vector)
Computes the dot product of this and the given vector.
|
double |
mag()
Computes the magnitude or length of this.
|
Vector2D |
mult(double scalar)
Multiplies this by the given scalar.
|
Vector2D |
sub(Vector2D vector)
Subtracts the given vector from this.
|
java.lang.String |
toString() |
public Vector2D(double x,
double y)
x - The x coordinate of the new vectory - The y coordinate of the new vectorpublic Vector2D sub(Vector2D vector)
vector - The vector to be subtracted from thispublic Vector2D add(Vector2D vector)
vector - The vector to be added to thispublic Vector2D mult(double scalar)
scalar - The scalar to be multiplied by thispublic double mag()
public double dot(Vector2D vector)
vector - The vector to be multiplied by thispublic double cross(Vector2D vector)
vector - The vector to be multiplied to the perpendicular vector of
thispublic java.lang.String toString()
toString in class java.lang.Object