public class Vector2
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static float |
TO_DEGREES |
static float |
TO_RADIANS |
float |
x |
float |
y |
Constructor and Description |
---|
Vector2()
Contructs a 2d vector with an x and y component of zero.
|
Vector2(float x,
float y)
Contructs a 2d vector with given x and y components.
|
Vector2(Vector2 other)
Constructs a vector using another vector's x and y components.
|
Modifier and Type | Method and Description |
---|---|
Vector2 |
add(float amount)
Adds the given amount to the x and y components of this Vector.
|
Vector2 |
add(float x,
float y)
Adds the x and y arguments to the x and y components of this Vector.
|
Vector2 |
add(Vector2 other)
Adds a vector to this vector.
|
float |
angle()
Returns the angle formed by the vector, counterclockwise from the +x axis.
|
float |
distance(float x,
float y)
Returns the distance between this vector and the given x and y components, which form another vector.
|
float |
distance(Vector2 other)
Returns the distance between this vector and another vector.
|
float |
distSquared(float x,
float y)
Returns the distance squared between this vector and another vector with position (x,y).
|
float |
distSquared(Vector2 other)
Returns the distance squared between this vector and another vector.
|
float |
magnitude()
Returns the magnitude of this vector.
|
Vector2 |
mul(float scalar)
Multiplies this vector by a scalar.
|
Vector2 |
normalize()
Normalizes the vector.
|
Vector2 |
set(float x,
float y)
Sets the x and y components of the vector.
|
Vector2 |
set(Vector2 other)
Copies the x and y components of another vector into this vector.
|
Vector2 |
sub(float amount)
Subtracts the given amount from the x and y components of this Vector.
|
Vector2 |
sub(float x,
float y)
Subtracts the x and y arguments from the x and y components of this Vector.
|
Vector2 |
sub(Vector2 other)
Adds a vector form this vector.
|
java.lang.String |
toString() |
public static float TO_RADIANS
public static float TO_DEGREES
public float x
public float y
public Vector2()
public Vector2(float x, float y)
public Vector2(Vector2 other)
public Vector2 set(float x, float y)
public Vector2 set(Vector2 other)
public Vector2 add(float amount)
public Vector2 add(float x, float y)
public Vector2 add(Vector2 other)
public Vector2 sub(float amount)
public Vector2 sub(float x, float y)
public Vector2 sub(Vector2 other)
public Vector2 mul(float scalar)
public float magnitude()
public Vector2 normalize()
public float angle()
public float distance(Vector2 other)
public float distance(float x, float y)
public float distSquared(Vector2 other)
public float distSquared(float x, float y)
public java.lang.String toString()
toString
in class java.lang.Object