Class Vector2i
java.lang.Object
dev.prozilla.pine.common.math.vector.Vector<Vector2i>
dev.prozilla.pine.common.math.vector.VectorInt<Vector2i>
dev.prozilla.pine.common.math.vector.Vector2i
2-dimensional vector with integer precision. GLSL equivalent to
ivec2
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(int x, int y) Adds another vector to this vector.clone()
Returns a new object that is equal to this object.int
Calculates the dot product of this vector with another vector.static Vector2i
down()
Creates a new vector (0, -1)boolean
Checks if the given object is equal to this object.static Vector2i
getTemp
(int x, int y) Returns a temporary vector with given values.static Vector2i
left()
Creates a new vector (-1, 0)int
Calculates the squared length of this vector.static Vector2i
static Vector2i
right()
Creates a new vector (1, 0)scale
(float scalar) Scales this vector by a scalar.void
Stores the vector in a given buffer.toString()
Converts this vector to a string representation in the format "(x,y)".static Vector2i
up()
Creates a new vector (0, 1)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 int x -
y
public int y -
temp
Reusable temporary vector, to avoid repeatedly creating new instances in performance-critical contexts.
-
-
Constructor Details
-
Vector2i
public Vector2i()Creates a default 2-dimensional vector with all values set to0
. -
Vector2i
public Vector2i(int x, int 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 int lengthSquared()Description copied from class:VectorInt
Calculates the squared length of this vector.- Specified by:
lengthSquared
in classVectorInt<Vector2i>
-
dot
Description copied from class:VectorInt
Calculates the dot product of this vector with another vector. -
toBuffer
Description copied from class:VectorInt
Stores the vector in a given buffer. -
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.
-