Interface Vector<S extends Space,V extends Vector<S,V>>

Type Parameters:
S - Type of the space.
V - Type of vector implementing this interface.
All Superinterfaces:
Blendable<Vector<S,V>>, Point<S>, Serializable
All Known Implementing Classes:
Vector1D, Vector2D, Vector3D

public interface Vector<S extends Space,V extends Vector<S,V>> extends Point<S>, Blendable<Vector<S,V>>
This interface represents a generic vector in a vectorial space or a point in an affine space.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    add(double factor, Vector<S,V> v)
    Add a scaled vector to the instance.
    add(Vector<S,V> v)
    Add a vector to the instance.
    default V
    blendArithmeticallyWith(Vector<S,V> other, double blendingValue)
    Blend arithmetically this instance with another one.
    double
    Compute the distance between the instance and another vector according to the L1 norm.
    double
    Compute the distance between the instance and another vector according to the L norm.
    double
    Compute the square of the distance between the instance and another vector.
    double
    Compute the dot-product of the instance and another vector.
    double
    Get the L2 norm for the vector.
    double
    Get the L1 norm for the vector.
    double
    Get the L norm for the vector.
    double
    Get the square of the norm for the vector.
    Get the null vector of the vectorial space or origin point of the affine space.
    boolean
    Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
    Get the opposite of the instance.
    default V
    Get a normalized vector aligned with the instance.
    scalarMultiply(double a)
    Multiply the instance by a scalar.
    subtract(double factor, Vector<S,V> v)
    Subtract a scaled vector from the instance.
    Subtract a vector from the instance.
    Get a string representation of this vector.

    Methods inherited from interface org.hipparchus.geometry.Point

    distance, getSpace, isNaN
  • Method Details

    • getZero

      V getZero()
      Get the null vector of the vectorial space or origin point of the affine space.
      Returns:
      null vector of the vectorial space or origin point of the affine space
    • getNorm1

      double getNorm1()
      Get the L1 norm for the vector.
      Returns:
      L1 norm for the vector
    • getNorm

      double getNorm()
      Get the L2 norm for the vector.
      Returns:
      Euclidean norm for the vector
    • getNormSq

      double getNormSq()
      Get the square of the norm for the vector.
      Returns:
      square of the Euclidean norm for the vector
    • getNormInf

      double getNormInf()
      Get the L norm for the vector.
      Returns:
      L norm for the vector
    • add

      V add(Vector<S,V> v)
      Add a vector to the instance.
      Parameters:
      v - vector to add
      Returns:
      a new vector
    • add

      V add(double factor, Vector<S,V> v)
      Add a scaled vector to the instance.
      Parameters:
      factor - scale factor to apply to v before adding it
      v - vector to add
      Returns:
      a new vector
    • subtract

      V subtract(Vector<S,V> v)
      Subtract a vector from the instance.
      Parameters:
      v - vector to subtract
      Returns:
      a new vector
    • subtract

      V subtract(double factor, Vector<S,V> v)
      Subtract a scaled vector from the instance.
      Parameters:
      factor - scale factor to apply to v before subtracting it
      v - vector to subtract
      Returns:
      a new vector
    • negate

      V negate()
      Get the opposite of the instance.
      Returns:
      a new vector which is opposite to the instance
    • normalize

      default V normalize() throws MathRuntimeException
      Get a normalized vector aligned with the instance.
      Returns:
      a new normalized vector
      Throws:
      MathRuntimeException - if the norm is zero
    • scalarMultiply

      V scalarMultiply(double a)
      Multiply the instance by a scalar.
      Parameters:
      a - scalar
      Returns:
      a new vector
    • isInfinite

      boolean isInfinite()
      Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
      Returns:
      true if any coordinate of this vector is infinite and none are NaN; false otherwise
    • distance1

      double distance1(Vector<S,V> v)
      Compute the distance between the instance and another vector according to the L1 norm.

      Calling this method is equivalent to calling: q.subtract(p).getNorm1() except that no intermediate vector is built

      Parameters:
      v - second vector
      Returns:
      the distance between the instance and p according to the L1 norm
    • distanceInf

      double distanceInf(Vector<S,V> v)
      Compute the distance between the instance and another vector according to the L norm.

      Calling this method is equivalent to calling: q.subtract(p).getNormInf() except that no intermediate vector is built

      Parameters:
      v - second vector
      Returns:
      the distance between the instance and p according to the L norm
    • distanceSq

      double distanceSq(Vector<S,V> v)
      Compute the square of the distance between the instance and another vector.

      Calling this method is equivalent to calling: q.subtract(p).getNormSq() except that no intermediate vector is built

      Parameters:
      v - second vector
      Returns:
      the square of the distance between the instance and p
    • dotProduct

      double dotProduct(Vector<S,V> v)
      Compute the dot-product of the instance and another vector.
      Parameters:
      v - second vector
      Returns:
      the dot product this.v
    • toString

      String toString(NumberFormat format)
      Get a string representation of this vector.
      Parameters:
      format - the custom format for components
      Returns:
      a string representation of this vector
    • blendArithmeticallyWith

      default V blendArithmeticallyWith(Vector<S,V> other, double blendingValue) throws MathIllegalArgumentException
      Blend arithmetically this instance with another one.
      Specified by:
      blendArithmeticallyWith in interface Blendable<S extends Space>
      Parameters:
      other - other instance to blend arithmetically with
      blendingValue - value from smoothstep function B(x). It is expected to be between [0:1] and will throw an exception otherwise.
      Returns:
      this * (1 - B(x)) + other * B(x)
      Throws:
      MathIllegalArgumentException - if blending value is not within [0:1]