java.lang.Object
com.github.stephengold.joltjni.Float4
All Implemented Interfaces:
ConstFloat4

public final class Float4 extends Object implements ConstFloat4
A vector composed of 4 single-precision components, used as a storage class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    the 4th (W) component
    float
    the first (X) component
    float
    the 2nd (Y) component
    float
    the 3rd (Z) component
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate an all-zero vector (0,0,0,0).
    Float4(float x, float y, float z, float w)
    Instantiate a vector with specified components.
    Instantiate a copy of the specified vector.
    Instantiate from the specified buffer.
    Float4(FloatBuffer buffer, int startPos)
    Instantiate from the specified position in the specified buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    get(int index)
    Return the specified component.
    void
    put(FloatBuffer storeBuffer)
    Write all 4 components to the specified buffer and advance the buffer's position by 4.
    void
    set(float[] array)
    Set all 4 components from the specified array.
    void
    set(float x, float y, float z, float w)
    Set all 4 components to specified values.
    void
    set(FloatBuffer buffer)
    Set all 4 components from the specified buffer.
    Return a string representation of the vector, which is unaffected.
    float
    w()
    Return the 4th (W) component.
    float
    x()
    Return the first (X) component.
    float
    y()
    Return the 2nd (Y) component.
    float
    z()
    Return the 3rd (Z) component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • w

      public float w
      the 4th (W) component
    • x

      public float x
      the first (X) component
    • y

      public float y
      the 2nd (Y) component
    • z

      public float z
      the 3rd (Z) component
  • Constructor Details

    • Float4

      public Float4()
      Instantiate an all-zero vector (0,0,0,0).
    • Float4

      public Float4(float x, float y, float z, float w)
      Instantiate a vector with specified components.
      Parameters:
      x - the desired X component
      y - the desired Y component
      z - the desired Z component
      w - the desired W component
    • Float4

      public Float4(ConstFloat4 rhs)
      Instantiate a copy of the specified vector.
      Parameters:
      rhs - the vector to copy (not null, unaffected)
    • Float4

      public Float4(FloatBuffer buffer)
      Instantiate from the specified buffer.
      Parameters:
      buffer - the desired component values (not null, unaffected, capacity≥4)
    • Float4

      public Float4(FloatBuffer buffer, int startPos)
      Instantiate from the specified position in the specified buffer.
      Parameters:
      buffer - the desired component values (not null, unaffected)
      startPos - the starting position in the buffer (≥0)
  • Method Details

    • set

      public void set(float x, float y, float z, float w)
      Set all 4 components to specified values.
      Parameters:
      x - the desired X component
      y - the desired Y component
      z - the desired Z component
      w - the desired W component
    • set

      public void set(float[] array)
      Set all 4 components from the specified array.
      Parameters:
      array - the desired component values (not null, length≥4, unaffected)
    • set

      public void set(FloatBuffer buffer)
      Set all 4 components from the specified buffer.
      Parameters:
      buffer - the desired component values (not null, length≥4, unaffected)
    • get

      public float get(int index)
      Return the specified component. The vector is unaffected.
      Specified by:
      get in interface ConstFloat4
      Parameters:
      index - 0, 1, 2, or 3
      Returns:
      the X component if index=0, the Y component if index=1, the Z component if index=2, or the W component if index=3
      Throws:
      IllegalArgumentException - if index is not 0, 1, 2, or 3
    • put

      public void put(FloatBuffer storeBuffer)
      Write all 4 components to the specified buffer and advance the buffer's position by 4. The vector is unaffected.
      Specified by:
      put in interface ConstFloat4
      Parameters:
      storeBuffer - the destination buffer (not null)
    • w

      public float w()
      Return the 4th (W) component. The vector is unaffected.
      Specified by:
      w in interface ConstFloat4
      Returns:
      the component value
    • x

      public float x()
      Return the first (X) component. The vector is unaffected.
      Specified by:
      x in interface ConstFloat4
      Returns:
      the component value
    • y

      public float y()
      Return the 2nd (Y) component. The vector is unaffected.
      Specified by:
      y in interface ConstFloat4
      Returns:
      the component value
    • z

      public float z()
      Return the 3rd (Z) component. The vector is unaffected.
      Specified by:
      z in interface ConstFloat4
      Returns:
      the component value
    • toString

      public String toString()
      Return a string representation of the vector, which is unaffected. For example, a zero vector is represented by:
       Float4(0.0 0.0 0.0 0.0)
       
      Overrides:
      toString in class Object
      Returns:
      the string representation (not null, not empty)