java.lang.Object
dev.aurumbyte.sypherengine.math.Vector2
The Vector2 class of SypherEngine, the base of all position
- Since:
- 0.3.0
- Author:
- AurumByte
-
Field Summary
Modifier and TypeFieldDescription(package private) float
The rotation of the vectorfloat
The xPos and yPos (in float)int
The integer position of xPos and yPos, for people who are too lazy to cast to int XDfloat
The xPos and yPos (in float)int
The integer position of xPos and yPos, for people who are too lazy to cast to int XD -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a Vector2 with another Vector2static double
Calculates the distance between two vectorsvoid
Divides a Vector2 with another Vector2Gets the vector positionfloat
Gets the rotation of the Vectorvoid
Multiplies a Vector2 with another Vector2void
Normalizes the Vectorvoid
rotate
(float rotation) Rotates the Vectorvoid
setPosition
(float xPos, float yPos) Set the Vector's positionvoid
Subtracts a Vector2 with another Vector2
-
Field Details
-
xPosi
public int xPosiThe integer position of xPos and yPos, for people who are too lazy to cast to int XD -
yPosi
public int yPosiThe integer position of xPos and yPos, for people who are too lazy to cast to int XD -
xPos
public float xPosThe xPos and yPos (in float) -
yPos
public float yPosThe xPos and yPos (in float) -
rotation
float rotationThe rotation of the vector
-
-
Constructor Details
-
Vector2
public Vector2()Create an empty Vector of coords (0, 0)
- Since:
- 0.3.0
-
Vector2
public Vector2(float x, float y) Creates a Vector2 instance with x and y position
- Parameters:
x
- x positiony
- y position- Since:
- 0.3.0
-
Vector2
public Vector2(float x, float y, float rotation) Creates a Vector2 instance with a specified position and rotation
- Parameters:
x
- x positiony
- y positionrotation
- rotation of the vector- Since:
- 0.3.0
-
-
Method Details
-
add
Adds a Vector2 with another Vector2
- Parameters:
vector2
- The other Vector- Since:
- 0.3.0
-
subtract
Subtracts a Vector2 with another Vector2
- Parameters:
vector2
- The other Vector- Since:
- 0.3.0
-
multiply
Multiplies a Vector2 with another Vector2
- Parameters:
vector2
- The other Vector- Since:
- 0.3.0
-
divide
Divides a Vector2 with another Vector2
- Parameters:
vector2
- The other Vector- Since:
- 0.3.0
-
rotate
public void rotate(float rotation) Rotates the Vector
- Parameters:
rotation
- The amount of rotation needed for the vector- Since:
- 0.3.0
-
setPosition
public void setPosition(float xPos, float yPos) Set the Vector's position
- Parameters:
xPos
- The x positionyPos
- The y position- Since:
- 0.3.0
-
getPosition
Gets the vector position
- Since:
- 0.3.0
-
getRotation
public float getRotation()Gets the rotation of the Vector
- Since:
- 0.3.0
-
normalize
public void normalize()Normalizes the Vector
- Since:
- v0.3.0
-
distance
Calculates the distance between two vectors
- Parameters:
a
- A Vectorb
- Another vector
-