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
.-
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.float
Calculates the dot product of this vector with another vector.static Vector2f
down()
Creates a new vector (0, -1)boolean
Checks if the given object is equal to this object.static Vector2f
getTemp
(float x, float y) Returns a temporary vector with given values.static Vector2f
left()
Creates a new vector (-1, 0)float
Calculates the squared length of this vector.static Vector2f
static Vector2f
right()
Creates a new vector (1, 0)scale
(float scalar) Scales this vector by a scalar.void
toBuffer
(FloatBuffer buffer) Stores the vector in a given buffer.toString()
Converts this vector to a string representation in the format "(x,y)".static Vector2f
up()
Creates a new vector (0, 1)Methods inherited from class dev.prozilla.pine.common.math.vector.VectorFloat
length
Methods inherited from class dev.prozilla.pine.common.math.vector.Vector
divide, equals, hashCode, lerp, negate, normalize, parseToFloats, parseToFloats, parseToIntegers, parseToIntegers, parseToNumbers, subtract
-
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
-
add
-
add
Description copied from class:Vector
Adds another vector to this vector. -
scale
Description copied from class:Vector
Scales this vector by a scalar. -
lengthSquared
public float lengthSquared()Description copied from class:VectorFloat
Calculates the squared length of this vector.- Specified by:
lengthSquared
in classVectorFloat<Vector2f>
-
dot
Description copied from class:VectorFloat
Calculates the dot product of this vector with another vector.- Specified by:
dot
in classVectorFloat<Vector2f>
- Returns:
- Dot product of this vector multiplied by another vector
-
toBuffer
Description copied from class:VectorFloat
Stores the vector in a given buffer.- Specified by:
toBuffer
in classVectorFloat<Vector2f>
- Parameters:
buffer
- The buffer to store the vector data in
-
equals
Description copied from interface:Cloneable
Checks if the given object is equal to this object. -
clone
Description copied from interface:Cloneable
Returns a new object that is equal to this object. -
toString
Converts this vector to a string representation in the format "(x,y)". -
parse
- Throws:
InvalidStringException
-
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.
-