Interface BigVector<N,D,V extends BigVector<N,D,V,DV,PV>,DV extends BigVector<D,D,DV,DV,? extends BaseTuple<?>>,PV extends BaseTuple<? extends Number>>

Type Parameters:
N - The type of number to use
D - The type of decimal number to use
V - The vector itself (the parameter and result of various operations)
DV - The type of decimal vector to use (the result of normalization)
PV - The primitive vector of which this vector can be converted to
All Superinterfaces:
BaseTuple<N>, Iterable<N>, Serializable, Tuple<N>
All Known Subinterfaces:
DecimalVector<V,PV>, IntegerVector<V,DV,PV>
All Known Implementing Classes:
Decimal2, Decimal3, Decimal4, DecimalQuaternion, Integer2, Integer3, Integer4

public interface BigVector<N,D,V extends BigVector<N,D,V,DV,PV>,DV extends BigVector<D,D,DV,DV,? extends BaseTuple<?>>,PV extends BaseTuple<? extends Number>> extends Tuple<N>
A mathematical vector which uses an arbitrary numeric type N.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(N s)
    Adds a scalar to this vector component-wise, then returns the resulting vector.
    add(V v)
    Adds another vector to this vector, then returns the resulting vector.
    clamp(V min, V max)
    Between this vector and the provided boundary vectors min and max, this returns a new vector whose components are clamped to respect the range of [min, max].
    Returns the Euclidean distance between this vector and the provided vector v.
    Returns the squared Euclidean distance between this vector and the provided vector v.
    Returns the Manhattan distance between this vector and the provided vector v.
    divide(N s)
    Divides this vector by a scalar component-wise, then returns the resulting vector.
    dot(V v)
    Returns the dot product between this vector and the provided vector v.
    boolean
    equals(V v)
    Checks for equality between this vector and the provided vector v.
    max(V v)
    Between this vector and the provided boundary vector v, this takes the maximum of each corresponding pair of components, then returns a new vector whose components are populated from that of the maximum values between each pair of components.
    Between this vector and the provided vector v, this applies the merger function f to each corresponding pair of components, then returns a new vector whose components are populated from the return values of the function f.
    min(V v)
    Between this vector and the provided boundary vector v, this takes the minimum of each corresponding pair of components, then returns a new vector whose components are populated from that of the minimum values between each pair of components.
    Multiplies this vector by a scalar component-wise, then returns the resulting vector.
    Negates all components of this vector, then returns the resulting vector.
    Returns the Euclidean norm (the magnitude) of this vector.
    Returns the squared Euclidean norm (the squared magnitude) of this vector.
    Normalizes this vector to have a Euclidean norm (magnitude) of 1.
    Normalizes this vector to have a Euclidean norm (magnitude) of 1.
    Normalizes this vector ot have a Euclidean norm (magnitude) of 1.
    Returns the Manhattan norm of this vector.
    Converts this vector into a primitive vector.
    Subtracts this vector by a scalar component-wise, then returns the resulting vector.
    Subtracts another vector from this vector, then returns the resulting vector.
    Applies the provided transformation function f to each component of this vector, then returns a new vector containing the return values of the function f.

    Methods inherited from interface java.lang.Iterable

    spliterator

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

    array, contains, containsAll, equals, filter, forEach, forEach, get, iterator, list, map, mapToDouble, mapToFloat, mapToInt, mapToLong, merge, safeArray, size, stream, toString
  • Method Details

    • norm

      @Nonnull D norm()
      Returns the Euclidean norm (the magnitude) of this vector.
      Returns:
      The Euclidean norm of this vector
    • norm2

      @Nonnull N norm2()
      Returns the squared Euclidean norm (the squared magnitude) of this vector.
      Returns:
      The squared Euclidean norm of this vector
    • normManhattan

      @Nonnull N normManhattan()
      Returns the Manhattan norm of this vector.
      Returns:
      The Manhattan norm of this vector
    • add

      @Nonnull V add(@Nonnull N s)
      Adds a scalar to this vector component-wise, then returns the resulting vector.
      Parameters:
      s - The scalar of which to add to each component of this vector
      Returns:
      The resulting vector
    • subtract

      @Nonnull V subtract(@Nonnull N s)
      Subtracts this vector by a scalar component-wise, then returns the resulting vector.
      Parameters:
      s - The scalar of which to subtract from each component of this vector
      Returns:
      The resulting vector
    • multiply

      @Nonnull V multiply(@Nonnull N s)
      Multiplies this vector by a scalar component-wise, then returns the resulting vector.
      Parameters:
      s - The scalar of which to multiply each component of this vector by
      Returns:
      The resulting vector
    • divide

      @Nonnull V divide(@Nonnull N s) throws ArithmeticException
      Divides this vector by a scalar component-wise, then returns the resulting vector.
      Parameters:
      s - The scalar of which to divide each component of this vector by
      Returns:
      The resulting vector
      Throws:
      ArithmeticException - When the denominator s is zero
    • add

      @Nonnull V add(@Nonnull V v)
      Adds another vector to this vector, then returns the resulting vector.
      Parameters:
      v - The vector of which to add to this vector
      Returns:
      The resulting vector
    • subtract

      @Nonnull V subtract(@Nonnull V v)
      Subtracts another vector from this vector, then returns the resulting vector.
      Parameters:
      v - The vector of which to subtract from this vector
      Returns:
      The resulting vector
    • dot

      @Nonnull N dot(@Nonnull V v)
      Returns the dot product between this vector and the provided vector v.
      Parameters:
      v - The vector of which to get the dot product between
      Returns:
      The dot product between the two vectors
    • normalize

      @Nonnull DV normalize() throws ArithmeticException
      Normalizes this vector to have a Euclidean norm (magnitude) of 1.
      Returns:
      The normalized vector of this vector
      Throws:
      ArithmeticException - When the Euclidean norm of this vector is zero
    • normalizeOrZero

      @Nonnull DV normalizeOrZero()
      Normalizes this vector ot have a Euclidean norm (magnitude) of 1. If this vector's Euclidean norm is zero, this will return itself. (which is guaranteed to be a vector where all components are zero, as only zero vectors have a Euclidean norm of zero)
      Returns:
      The normalized vector of this vector if successful, zero otherwise
    • normalizeOrDefault

      @Nonnull DV normalizeOrDefault(@Nonnull DV v)
      Normalizes this vector to have a Euclidean norm (magnitude) of 1. If this vector's Euclidean norm is zero, this will return the provided fallback value v.
      Parameters:
      v - The value of which to return in case of division by zero
      Returns:
      The normalized vector of this vector if successful, the fallback value v otherwise
    • negate

      @Nonnull V negate()
      Negates all components of this vector, then returns the resulting vector.
      Returns:
      The negation of this vector
    • min

      @Nonnull V min(@Nonnull V v)
      Between this vector and the provided boundary vector v, this takes the minimum of each corresponding pair of components, then returns a new vector whose components are populated from that of the minimum values between each pair of components.
      Parameters:
      v - The boundary vector of which to compare to
      Returns:
      The minimum vector of the two vectors
    • max

      @Nonnull V max(@Nonnull V v)
      Between this vector and the provided boundary vector v, this takes the maximum of each corresponding pair of components, then returns a new vector whose components are populated from that of the maximum values between each pair of components.
      Parameters:
      v - The boundary vector of which to compare to
      Returns:
      The maximum vector of the two vectors
    • clamp

      @Nonnull V clamp(@Nonnull V min, @Nonnull V max)
      Between this vector and the provided boundary vectors min and max, this returns a new vector whose components are clamped to respect the range of [min, max]. This is the equivalent of clamping each component to the corresponding pair of minimum and maximum values.
      Parameters:
      min - The minimum boundary vector to compare to
      max - The maximum boundary vector to compare to
      Returns:
      The clamped vector which respects the boundaries of [min, max]
    • distance

      @Nonnull D distance(@Nonnull V v)
      Returns the Euclidean distance between this vector and the provided vector v.
      Parameters:
      v - The vector of which get the Euclidean distance between
      Returns:
      The Euclidean distance between the two vectors
    • distance2

      @Nonnull N distance2(@Nonnull V v)
      Returns the squared Euclidean distance between this vector and the provided vector v.
      Parameters:
      v - The vector of which to get the squared Euclidean distance between
      Returns:
      The squared Euclidean distance between the two vectors
    • distanceManhattan

      @Nonnull N distanceManhattan(@Nonnull V v)
      Returns the Manhattan distance between this vector and the provided vector v.
      Parameters:
      v - The vector of which to get the Manhattan distance between
      Returns:
      The Manhattan distance between the two vectors
    • transform

      @Nonnull V transform(@Nonnull UnaryOperator<N> f)
      Applies the provided transformation function f to each component of this vector, then returns a new vector containing the return values of the function f.
      Parameters:
      f - The function of which to apply to each component of this vector
      Returns:
      The resulting vector
    • merge

      @Nonnull V merge(@Nonnull V v, @Nonnull BinaryOperator<N> f)
      Between this vector and the provided vector v, this applies the merger function f to each corresponding pair of components, then returns a new vector whose components are populated from the return values of the function f.
      Parameters:
      v - The vector of which to merge this vector with
      f - The merger function to handle the merging of the two vectors
      Returns:
      The resulting vector
    • primValue

      @Nonnull PV primValue()
      Converts this vector into a primitive vector. Precision and/or scale may be lost.
      Returns:
      The primitive representation of this vector
    • equals

      boolean equals(@Nullable V v)
      Checks for equality between this vector and the provided vector v.
      Parameters:
      v - The vector to compare to
      Returns:
      true if the component values are equal