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

public final class Float2 extends Object
A vector composed of 2 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
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate an all-zero vector (0,0,0).
    Float2(float x, float y)
    Instantiate a vector with specified components.
    Instantiate a copy of the specified vector.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    get(int index)
    Return the specified component.
    void
    put(FloatBuffer storeBuffer)
    Write both components to the specified buffer and advance the buffer's position by 2.
    void
    set(float[] array)
    Set both components from the specified array.
    void
    set(float x, float y)
    Set both 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
  • Constructor Details

    • Float2

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

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

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

    • get

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

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

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

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

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