Vector2

Constructors

this
this(float x, float y)

Members

Functions

angleTo
float angleTo(Vector2 vector)

Returns the angle to the vector in degrees

distanceTo
float distanceTo(Vector2 vector)

Returns the distance between the vectors

distanceToSquared
float distanceToSquared(Vector2 vector)

Returns the squared distance between the vectors

dot
float dot(Vector2 vector)

Returns the dot product of the two vectors

getDirection
float getDirection()

Returns the direction of the vector in degrees

getMagnitude
float getMagnitude()

Returns the magnitude of the vector

getNormalized
Vector2 getNormalized()

Returns a normalized copy of this vector

normalize
void normalize()

Normalizes the vector

set
void set(float x, float y)

Sets the values of x and y in a single statement

setDirection
void setDirection(float angle)

Sets the direction of the vector using degrees

setMagnitude
void setMagnitude(float magnitude)

Sets the magnitude of this vector

Static functions

random
Vector2 random()

Creates a normalized vector with a random direction

Variables

x
float x;
y
float y;

Meta