Class Vector2f
java.lang.Object
dev.prozilla.pine.common.math.vector.Vector<Vector2f>
dev.prozilla.pine.common.math.vector.VectorFloat<Vector2f>
dev.prozilla.pine.common.math.vector.Vector2f
2-dimensional vector with floating point precision. GLSL equivalent to
vec2.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(float x, float y) Adds another vector to this vector.clone()Returns a new object that is equal to this object.static floatdistance(float x1, float y1, float x2, float y2) floatstatic floatdistanceSquared(float x1, float y1, float x2, float y2) floatdistanceSquared(Vector2f vector2f) floatCalculates the dot product of this vector with another vector.static Vector2fdown()Creates a new vector (0, -1)booleanChecks if the given object is equal to this object.static Vector2fgetTemp(float x, float y) Returns a temporary vector with given values.inthashCode()booleanisZero()static Vector2fleft()Creates a new vector (-1, 0)floatCalculates the squared length of this vector.static Vector2fone()Creates a new vector (1, 1)static Vector2fright()Creates a new vector (1, 0)scale(float scalar) Scales this vector by a scalar.set(float xy) set(float x, float y) Subtracts another vector from this vector.voidtoBuffer(FloatBuffer buffer) Stores the vector in a given buffer.@NotNull StringtoString()Converts this vector to a string representation in the format "(x,y)".static Vector2fup()Creates a new vector (0, 1)Methods inherited from class dev.prozilla.pine.common.math.vector.VectorFloat
lengthMethods inherited from class dev.prozilla.pine.common.math.vector.Vector
divide, equals, lerp, negate, normalize, parseToFloats, parseToFloats, parseToIntegers, parseToIntegers, parseToNumbers
-
Field Details
-
x
public float x -
y
public float y -
temp
Reusable temporary vector, to avoid repeatedly creating new instances in performance-critical contexts.
-
-
Constructor Details
-
Vector2f
public Vector2f()Creates a default 2-dimensional vector with all values set to0f. -
Vector2f
public Vector2f(float x, float y) Creates a 2-dimensional vector with given values.
-
-
Method Details
-
set
-
set
-
add
-
add
Description copied from class:VectorAdds another vector to this vector. -
subtract
Description copied from class:VectorSubtracts another vector from this vector. -
scale
Description copied from class:VectorScales this vector by a scalar. -
lengthSquared
public float lengthSquared()Description copied from class:VectorFloatCalculates the squared length of this vector.- Specified by:
lengthSquaredin classVectorFloat<Vector2f>
-
dot
Description copied from class:VectorFloatCalculates the dot product of this vector with another vector.- Specified by:
dotin classVectorFloat<Vector2f>- Returns:
- Dot product of this vector multiplied by another vector
-
distance
-
distanceSquared
-
isZero
public boolean isZero() -
toBuffer
Description copied from class:VectorFloatStores the vector in a given buffer.- Specified by:
toBufferin classVectorFloat<Vector2f>- Parameters:
buffer- The buffer to store the vector data in
-
toDirection
-
hashCode
public int hashCode() -
equals
Description copied from interface:CloneableChecks if the given object is equal to this object. -
clone
Description copied from interface:CloneableReturns a new object that is equal to this object. -
toString
Converts this vector to a string representation in the format "(x,y)". -
one
Creates a new vector (1, 1) -
up
Creates a new vector (0, 1) -
down
Creates a new vector (0, -1) -
left
Creates a new vector (-1, 0) -
right
Creates a new vector (1, 0) -
getTemp
Returns a temporary vector with given values. Note that this temporary vector is a global instance, so avoid concurrent usage. -
distance
public static float distance(float x1, float y1, float x2, float y2) -
distanceSquared
public static float distanceSquared(float x1, float y1, float x2, float y2)
-