Class Float3

java.lang.Object
civitas.celestis.util.tuple.Float3
All Implemented Interfaces:
BaseTuple<Float>, FloatTuple, Serializable

public class Float3 extends Object implements FloatTuple
An immutable type containing three primitive floats.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final float
    The X component of this tuple.
    protected final float
    The Y component of this tuple.
    protected final float
    The Z component of this tuple.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Float3(float[] components)
    Creates a new Float3.
    Float3(float x, float y, float z)
    Creates a new Float3.
    Creates a new Float3.
  • Method Summary

    Modifier and Type
    Method
    Description
    float[]
    Returns an array containing the components of this tuple in their proper order.
    Returns a tuple containing the components of this tuple in their boxed form.
    boolean
    contains(float v)
    Checks if this tuple contains the provided value v.
    boolean
    Checks if this tuple contains multiple values.
    boolean
    Checks for equality between this tuple and the provided object obj.
    float
    get(int i)
    Returns the ith component of this tuple.
    int
    Returns the hash code of this instance.
    boolean
    Returns whether this tuple is finite.
    boolean
    Returns whether this tuple is infinite.
    boolean
    Returns whether this tuple contains Float.NaN.
    boolean
    Returns whether this tuple represents zero.
    Returns an unmodifiable list containing the components of this tuple in their proper order.
    Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
    <F> Tuple<F>
    mapToObj(FloatFunction<? extends F> f)
    Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
    int
    Returns the size of this tuple.
    Returns a stream whose source is the elements of this tuple.
    Serializes this tuple into a string.
    float
    x()
    Returns the X component of this tuple.
    float
    y()
    Returns the Y component of this tuple.
    float
    z()
    Returns the Z component of this tuple.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface civitas.celestis.util.tuple.FloatTuple

    floatArray
  • Field Details

    • x

      protected final float x
      The X component of this tuple.
    • y

      protected final float y
      The Y component of this tuple.
    • z

      protected final float z
      The Z component of this tuple.
  • Constructor Details

    • Float3

      public Float3(float x, float y, float z)
      Creates a new Float3.
      Parameters:
      x - The X component of this tuple
      y - The Y component of this tuple
      z - The Z component of this tuple
    • Float3

      public Float3(@Nonnull float[] components)
      Creates a new Float3.
      Parameters:
      components - An array containing the components of this tuple in XYZ order
      Throws:
      IllegalArgumentException - When the provided array's length is not 3
    • Float3

      public Float3(@Nonnull FloatTuple t)
      Creates a new Float3.
      Parameters:
      t - The tuple of which to copy component values from
      Throws:
      IllegalArgumentException - When the provided tuple t's size is not 3
  • Method Details

    • size

      public int size()
      Returns the size of this tuple. (the number of components it has)
      Specified by:
      size in interface BaseTuple<Float>
      Specified by:
      size in interface FloatTuple
      Returns:
      The number of components this tuple has
    • isZero

      public boolean isZero()
      Returns whether this tuple represents zero. (whether every component is zero)
      Specified by:
      isZero in interface FloatTuple
      Returns:
      true if every component of this tuple is zero
    • isNaN

      public boolean isNaN()
      Returns whether this tuple contains Float.NaN.
      Specified by:
      isNaN in interface FloatTuple
      Returns:
      true if at least one component of this tuple is not a number
      See Also:
    • isFinite

      public boolean isFinite()
      Returns whether this tuple is finite.
      Specified by:
      isFinite in interface FloatTuple
      Returns:
      true if every component of this tuple is finite
      See Also:
    • isInfinite

      public boolean isInfinite()
      Returns whether this tuple is infinite.
      Specified by:
      isInfinite in interface FloatTuple
      Returns:
      true if at least one component of this tuple is infinite
      See Also:
    • contains

      public boolean contains(float v)
      Checks if this tuple contains the provided value v.
      Specified by:
      contains in interface FloatTuple
      Parameters:
      v - The value of which to check for containment
      Returns:
      true if at least one component of this tuple is equal to the provided value v
    • containsAll

      public boolean containsAll(@Nonnull Iterable<Float> i)
      Checks if this tuple contains multiple values.
      Specified by:
      containsAll in interface FloatTuple
      Parameters:
      i - The iterable object of which to check for containment
      Returns:
      true if this tuple contains every component of the iterable object
    • get

      public float get(int i) throws IndexOutOfBoundsException
      Returns the ith component of this tuple.
      Specified by:
      get in interface FloatTuple
      Parameters:
      i - The index of the component to get
      Returns:
      The ith component of this tuple
      Throws:
      IndexOutOfBoundsException - When the index i is out of bounds
    • x

      public float x()
      Returns the X component of this tuple.
      Returns:
      The X component of this tuple
    • y

      public float y()
      Returns the Y component of this tuple.
      Returns:
      The Y component of this tuple
    • z

      public float z()
      Returns the Z component of this tuple.
      Returns:
      The Z component of this tuple
    • map

      @Nonnull public Float3 map(@Nonnull FloatUnaryOperator f)
      Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
      Specified by:
      map in interface FloatTuple
      Parameters:
      f - The function of which to apply to each component of this tuple
      Returns:
      The resulting tuple
    • mapToObj

      @Nonnull public <F> Tuple<F> mapToObj(@Nonnull FloatFunction<? extends F> f)
      Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
      Specified by:
      mapToObj in interface FloatTuple
      Type Parameters:
      F - The type of component to map this tuple to
      Parameters:
      f - The function of which to apply to each component of this tuple
      Returns:
      The resulting tuple
    • array

      @Nonnull public float[] array()
      Returns an array containing the components of this tuple in their proper order.
      Specified by:
      array in interface FloatTuple
      Returns:
      The array representation of this tuple
    • stream

      @Nonnull public Stream<Float> stream()
      Returns a stream whose source is the elements of this tuple.
      Specified by:
      stream in interface FloatTuple
      Returns:
      A stream whose source is the elements of this tuple
      See Also:
    • list

      @Nonnull public List<Float> list()
      Returns an unmodifiable list containing the components of this tuple in their proper order.
      Specified by:
      list in interface BaseTuple<Float>
      Specified by:
      list in interface FloatTuple
      Returns:
      The list representation of this tuple
      See Also:
    • boxed

      @Nonnull public Tuple<Float> boxed()
      Returns a tuple containing the components of this tuple in their boxed form.
      Specified by:
      boxed in interface FloatTuple
      Returns:
      The boxed object representation of this tuple
      See Also:
    • equals

      public boolean equals(@Nullable Object obj)
      Checks for equality between this tuple and the provided object obj.
      Specified by:
      equals in interface FloatTuple
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare to
      Returns:
      true if the other object is also a float tuple, and the number of components, the order of the components, and the components' values are all equal
    • toString

      @Nonnull public String toString()
      Serializes this tuple into a string.
      Specified by:
      toString in interface FloatTuple
      Overrides:
      toString in class Object
      Returns:
      The string representation of this tuple
    • hashCode

      public int hashCode()
      Returns the hash code of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code of this instance