Class Vector4f

All Implemented Interfaces:
Cloneable<Vector4f>, Printable

public class Vector4f extends VectorFloat<Vector4f>
4-dimensional vector with floating point precision. GLSL equivalent to vec4.
  • Field Details

    • x

      public float x
    • y

      public float y
    • z

      public float z
    • w

      public float w
    • temp

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

    • Vector4f

      public Vector4f()
      Creates a default 4-dimensional vector with all values set to 0f.
    • Vector4f

      public Vector4f(float x, float y, float z, float w)
      Creates a 4-dimensional vector with given values.
  • Method Details

    • add

      public Vector4f add(float x, float y, float z, float w)
    • add

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

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

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

      public float dot(Vector4f vector4f)
      Description copied from class: VectorFloat
      Calculates the dot product of this vector with another vector.
      Specified by:
      dot in class VectorFloat<Vector4f>
      Returns:
      Dot product of this vector multiplied by another vector
    • toBuffer

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

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

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

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

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

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