java.lang.Object
com.github.stephengold.joltjni.Float3

public final class Float3 extends Object
A vector composed of 3 single-precision components, used as a storage class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    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).
    Float3(float x, float y, float z)
    Instantiate a vector with specified components.
    Instantiate a copy of the specified vector.
    Instantiate from a buffer.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • 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

    • Float3

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

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

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

      public Float3(FloatBuffer buffer)
      Instantiate from a buffer.
      Parameters:
      buffer - the desired component values (not null, unaffected, capacity≥3)
  • Method Details

    • get

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

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

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

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

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