Package io.github.espressoengine
Class Vector2
java.lang.Object
io.github.espressoengine.Vector2
Represents a 2D vector.
- Version:
- $Id: $Id
- Author:
- pastthepixels
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double amplitude, double direction) Returns a new vector with the current vector's position but moved toward a direction (in radians) by an amplitude.Returns a new vector with its position added from both the current vector and parametervector.clamp(double min, double max) Returns a new vector withUtils.clampused on both the x and y values for the vector.Returns a new vector withUtils.clampused on both the x and y values for the vector.booleanReturns true if two vectors have the same position.mult(double factor) Returns a new vector whose position is the current vector's multiplied by a factor.Returns a new vector whose position is the current vector's multiplied by parametervector's position.voidset(double x, double y) Sets the position of the vector from two numbers.voidSets the position of the vector to that of another vector.Returns a new vector with its position being the current vector's subtracted by parametervector.toString()toString.
-
Field Details
-
x
public double x -
y
public double y
-
-
Constructor Details
-
Vector2
public Vector2(double x, double y) Constructor for Vector2.
- Parameters:
x- a doubley- a double
-
Vector2
public Vector2()Constructor for Vector2.
-
-
Method Details
-
set
public void set(double x, double y) Sets the position of the vector from two numbers.- Parameters:
x- a doubley- a double
-
set
Sets the position of the vector to that of another vector.- Parameters:
vector- aVector2object
-
add
Returns a new vector with its position added from both the current vector and parametervector. -
add
Returns a new vector with the current vector's position but moved toward a direction (in radians) by an amplitude. NOTE: Direction is measured in RADIANS. You can just use an object's rotation -- its reference point is the same.- Parameters:
amplitude- a doubledirection- a double- Returns:
- a
Vector2object
-
sub
Returns a new vector with its position being the current vector's subtracted by parametervector. -
mult
Returns a new vector whose position is the current vector's multiplied by parametervector's position. -
mult
Returns a new vector whose position is the current vector's multiplied by a factor.- Parameters:
factor- a double- Returns:
- a
Vector2object
-
equals
Returns true if two vectors have the same position.- Parameters:
vector- aVector2object- Returns:
- a boolean
-
clamp
Returns a new vector with
Utils.clampused on both the x and y values for the vector. -
clamp
Returns a new vector with
Utils.clampused on both the x and y values for the vector.- Parameters:
min- a doublemax- a double- Returns:
- a
Vector2object
-
toString
toString.
-