Class Vector3i

All Implemented Interfaces:
Cloneable<Vector3i>, Printable

public class Vector3i extends VectorInt<Vector3i>
3-dimensional vector with integer precision. GLSL equivalent to ivec3.
  • Field Details

    • x

      public int x
    • y

      public int y
    • z

      public int z
    • temp

      public static final Vector3i temp
      Reusable temporary vector, to avoid repeatedly creating new instances in performance-critical contexts.
  • Constructor Details

    • Vector3i

      public Vector3i()
      Creates a default 3-dimensional vector with all values set to 0.
    • Vector3i

      public Vector3i(int x, int y, int z)
      Creates a 3-dimensional vector with given values.
  • Method Details

    • add

      public Vector3i add(int x, int y, int z)
    • add

      public Vector3i add(Vector3i vector3i)
      Description copied from class: Vector
      Adds another vector to this vector.
      Specified by:
      add in class Vector<Vector3i>
      Returns:
      Self
    • scale

      public Vector3i scale(float scalar)
      Description copied from class: Vector
      Scales this vector by a scalar.
      Specified by:
      scale in class Vector<Vector3i>
      Returns:
      Self
    • lengthSquared

      public int lengthSquared()
      Description copied from class: VectorInt
      Calculates the squared length of this vector.
      Specified by:
      lengthSquared in class VectorInt<Vector3i>
    • dot

      public int dot(Vector3i vector3i)
      Description copied from class: VectorInt
      Calculates the dot product of this vector with another vector.
      Specified by:
      dot in class VectorInt<Vector3i>
      Returns:
      Dot product of this vector multiplied by another vector
    • toBuffer

      public void toBuffer(IntBuffer buffer)
      Description copied from class: VectorInt
      Stores the vector in a given buffer.
      Specified by:
      toBuffer in class VectorInt<Vector3i>
      Parameters:
      buffer - The buffer to store the vector data in
    • equals

      public boolean equals(Vector3i vector)
      Description copied from interface: Cloneable
      Checks if the given object is equal to this object.
      Specified by:
      equals in interface Cloneable<Vector3i>
      Specified by:
      equals in class Vector<Vector3i>
      Parameters:
      vector - Other object
      Returns:
      true if both objects are equal.
    • clone

      public Vector3i clone()
      Description copied from interface: Cloneable
      Returns a new object that is equal to this object.
      Specified by:
      clone in interface Cloneable<Vector3i>
      Specified by:
      clone in class Vector<Vector3i>
      Returns:
      Clone of this object
    • toString

      public String toString()
      Converts this vector to a string representation in the format "(x,y,z)".
      Specified by:
      toString in interface Printable
      Specified by:
      toString in class Vector<Vector3i>
      Returns:
      String representation of this object.
    • parse

      public static Vector3i parse(String input) throws InvalidStringException
      Throws:
      InvalidStringException
    • getTemp

      public static Vector3i getTemp(int x, int y, int z)
      Returns a temporary vector with given values. Note that this temporary vector is a global instance, so avoid concurrent usage.