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
FieldsModifier and TypeFieldDescription(package private) floatThe rotation of the vectorfloatThe xPos and yPos (in float)intThe integer position of xPos and yPos, for people who are too lazy to cast to int XDfloatThe xPos and yPos (in float)intThe integer position of xPos and yPos, for people who are too lazy to cast to int XD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a Vector2 with another Vector2static doubleCalculates the distance between two vectorsvoidDivides a Vector2 with another Vector2Gets the vector positionfloatGets the rotation of the VectorvoidMultiplies a Vector2 with another Vector2voidNormalizes the Vectorvoidrotate(float rotation) Rotates the VectorvoidsetPosition(float xPos, float yPos) Set the Vector's positionvoidSubtracts 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
-