public class Vector2D
extends java.lang.Object
Constructor and Description |
---|
Vector2D(double dx,
double dy)
Create a new Vector2D.
|
Modifier and Type | Method and Description |
---|---|
Vector2D |
add(Vector2D v)
Create a new Vector2D by adding a vector to this one.
|
double |
dot(Vector2D v)
Calculate the dot product of this vector and another vector.
|
double |
getLength()
Get the length of this vector.
|
Vector2D |
getNormal()
Get a Vector2D that is normal to this one.
|
double |
getX()
Get the X component of this vector.
|
double |
getY()
Get the Y component of this vector.
|
Vector2D |
normalised()
Create a normalised version of this vector.
|
Vector2D |
scale(double amount)
Create a scaled version of this vector.
|
java.lang.String |
toString() |
public Vector2D(double dx, double dy)
dx
- The x component.dy
- The y component.public double getLength()
public double dot(Vector2D v)
v
- The other vector.public double getX()
public double getY()
public Vector2D add(Vector2D v)
v
- The vector to add.public Vector2D scale(double amount)
amount
- The scale factor.public Vector2D normalised()
public Vector2D getNormal()
public java.lang.String toString()
toString
in class java.lang.Object