Package org.collebol.shared.math
Class Vector2D
java.lang.Object
org.collebol.shared.math.Vector2D
This 2D game Vector represents a quantity with both direction and magnitude (length),
typically used for movement, velocity, and position. It is described by two components:
x (horizontal) and y (vertical).
- Since:
- 1.0-dev
- Author:
- ColleBol - contact@collebol.org
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd up two vectors.floatCalculate the distance between another vector.floatgetX()floatgetY()floatlength()Calculate the length (magnitude) of the vector.scale(float scalar) Multiply vector values with scalar.voidsetX(float x) voidsetY(float y) Subtract two vectors.
-
Constructor Details
-
Vector2D
public Vector2D(float x, float y)
-
-
Method Details
-
getX
public float getX() -
setX
public void setX(float x) -
getY
public float getY() -
setY
public void setY(float y) -
scale
Multiply vector values with scalar.- Parameters:
scalar- the value you want to multiply with- Returns:
- new vector with multiplied values.
-
length
public float length()Calculate the length (magnitude) of the vector.- Returns:
- magnitude
-