Package com.deco2800.game.utils.math
Class Vector2Utils
java.lang.Object
com.deco2800.game.utils.math.Vector2Utils
Contains additional utility constants and functions for common Vector2 operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
static final com.badlogic.gdx.math.Vector2
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
angleFromTo
(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to) Calculate the angle in degrees between two vectorsstatic double
angleTo
(com.badlogic.gdx.math.Vector2 vector) Calculate the angle in degrees of a vector.static com.badlogic.gdx.math.Vector2
angleToVector
(com.badlogic.gdx.math.Vector2 outVector, float angle) Find the vector relative to origin pointing in given anglestatic float
vectorToAngle
(com.badlogic.gdx.math.Vector2 vector) Calculate the angle in radians of a vector
-
Field Details
-
LEFT
public static final com.badlogic.gdx.math.Vector2 LEFT -
RIGHT
public static final com.badlogic.gdx.math.Vector2 RIGHT -
UP
public static final com.badlogic.gdx.math.Vector2 UP -
DOWN
public static final com.badlogic.gdx.math.Vector2 DOWN -
ONE
public static final com.badlogic.gdx.math.Vector2 ONE -
MAX
public static final com.badlogic.gdx.math.Vector2 MAX -
MIN
public static final com.badlogic.gdx.math.Vector2 MIN
-
-
Method Details
-
angleTo
public static double angleTo(com.badlogic.gdx.math.Vector2 vector) Calculate the angle in degrees of a vector.- Parameters:
vector
- The vector relative to the origin- Returns:
- Angle in degrees from -180 to 180
-
angleFromTo
public static double angleFromTo(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to) Calculate the angle in degrees between two vectors- Parameters:
from
- The vector from which angle is measuredto
- The vector to which angle is measured- Returns:
- Angle in degrees from -180 to 180
-
vectorToAngle
public static float vectorToAngle(com.badlogic.gdx.math.Vector2 vector) Calculate the angle in radians of a vector- Parameters:
vector
- The vector relative to origin- Returns:
- Angle in radians
-
angleToVector
public static com.badlogic.gdx.math.Vector2 angleToVector(com.badlogic.gdx.math.Vector2 outVector, float angle) Find the vector relative to origin pointing in given angle- Parameters:
outVector
- Output vector relative to originangle
- Angle in radians- Returns:
- Vector pointing in given angle
-