Interface VectorDouble<T extends VectorDouble<T>>

All Known Implementing Classes:
Vector2d, Vector3d, Vector4d

public interface VectorDouble<T extends VectorDouble<T>>
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    add(T v)
    Adds the given vector to this vector
    clamp(double min, double max)
    Clamps this vector's length to given min and max values
    cpy()
     
    double
    dot(T v)
     
    double
    dst(T v)
     
    double
    dst2(T v)
    This method is faster than dst(VectorDouble) because it avoids calculating a square root.
    boolean
    epsilonEquals(T other, double epsilon)
    Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
    boolean
     
    boolean
     
    interpolate(T target, double alpha, InterpolationDouble interpolator)
    Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method.
    boolean
    isCollinear(T other)
     
    boolean
    isCollinear(T other, double epsilon)
     
    boolean
     
    boolean
    isCollinearOpposite(T other, double epsilon)
     
    boolean
    isOnLine(T other)
     
    boolean
    isOnLine(T other, double epsilon)
     
    boolean
     
    boolean
    isPerpendicular(T other, double epsilon)
     
    boolean
     
    boolean
    isUnit(double margin)
     
    boolean
     
    boolean
    isZero(double margin)
     
    double
    len()
     
    double
    This method is faster than len() because it avoids calculating a square root.
    lerp(T target, double alpha)
    Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].
    limit(double limit)
    Limits the length of this vector, based on the desired maximum length.
    limit2(double limit2)
    Limits the length of this vector, based on the desired maximum length squared.
    mulAdd(T v, double scalar)
    First scale a supplied vector, then add it to this vector.
    mulAdd(T v, T mulVec)
    First scale a supplied vector, then add it to this vector.
    nor()
    Normalizes this vector.
    scl(double scalar)
    Scales this vector by a scalar
    scl(T v)
    Scales this vector by another vector
    set(T v)
    Sets this vector from the given vector
    setLength(double len)
    Sets the length of this vector.
    setLength2(double len2)
    Sets the length of this vector, based on the square of the desired length.
    Sets this vector to the unit vector with a random direction
    Sets the components of this vector to 0.
    sub(T v)
    Subtracts the given vector from this vector.
  • Method Details Link icon

    • cpy Link icon

      T cpy()
      Returns:
      a copy of this vector
    • len Link icon

      double len()
      Returns:
      The euclidean length
    • len2 Link icon

      double len2()
      This method is faster than len() because it avoids calculating a square root. It is useful for comparisons, but not for getting exact lengths, as the return value is the square of the actual length.
      Returns:
      The squared euclidean length
    • limit Link icon

      T limit(double limit)
      Limits the length of this vector, based on the desired maximum length.
      Parameters:
      limit - desired maximum length for this vector
      Returns:
      this vector for chaining
    • limit2 Link icon

      T limit2(double limit2)

      Limits the length of this vector, based on the desired maximum length squared.

      This method is slightly faster than limit().
      Parameters:
      limit2 - squared desired maximum length for this vector
      Returns:
      this vector for chaining
      See Also:
    • setLength Link icon

      T setLength(double len)
      Sets the length of this vector. Does nothing is this vector is zero.
      Parameters:
      len - desired length for this vector
      Returns:
      this vector for chaining
    • setLength2 Link icon

      T setLength2(double len2)

      Sets the length of this vector, based on the square of the desired length. Does nothing is this vector is zero.

      This method is slightly faster than setLength().
      Parameters:
      len2 - desired square of the length for this vector.
      Returns:
      this vector for chaining.
      See Also:
    • clamp Link icon

      T clamp(double min, double max)
      Clamps this vector's length to given min and max values
      Parameters:
      min - Min length
      max - Max length
      Returns:
      This vector for chaining
    • set Link icon

      T set(T v)
      Sets this vector from the given vector
      Parameters:
      v - The vector
      Returns:
      This vector for chaining
    • sub Link icon

      T sub(T v)
      Subtracts the given vector from this vector.
      Parameters:
      v - The vector
      Returns:
      This vector for chaining
    • nor Link icon

      T nor()
      Normalizes this vector. Does nothing if it is zero.
      Returns:
      This vector for chaining
    • add Link icon

      T add(T v)
      Adds the given vector to this vector
      Parameters:
      v - The vector
      Returns:
      This vector for chaining
    • dot Link icon

      double dot(T v)
      Parameters:
      v - The other vector
      Returns:
      The dot product between this and the other vector
    • scl Link icon

      T scl(double scalar)
      Scales this vector by a scalar
      Parameters:
      scalar - The scalar
      Returns:
      This vector for chaining
    • scl Link icon

      T scl(T v)
      Scales this vector by another vector
      Returns:
      This vector for chaining
    • dst Link icon

      double dst(T v)
      Parameters:
      v - The other vector
      Returns:
      the distance between this and the other vector
    • dst2 Link icon

      double dst2(T v)
      This method is faster than dst(VectorDouble) because it avoids calculating a square root. It is useful for comparisons, but not for getting accurate distances, as the return value is the square of the actual distance.
      Parameters:
      v - The other vector
      Returns:
      the squared distance between this and the other vector
    • lerp Link icon

      T lerp(T target, double alpha)
      Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.
      Parameters:
      target - The target vector
      alpha - The interpolation coefficient
      Returns:
      This vector for chaining.
    • interpolate Link icon

      T interpolate(T target, double alpha, InterpolationDouble interpolator)
      Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method. the result is stored in this vector.
      Parameters:
      target - The target vector
      alpha - The interpolation coefficient
      interpolator - An Interpolation object describing the used interpolation method
      Returns:
      This vector for chaining.
    • setToRandomDirection Link icon

      T setToRandomDirection()
      Sets this vector to the unit vector with a random direction
      Returns:
      This vector for chaining
    • isUnit Link icon

      boolean isUnit()
      Returns:
      Whether this vector is a unit length vector
    • isUnit Link icon

      boolean isUnit(double margin)
      Returns:
      Whether this vector is a unit length vector within the given margin.
    • isZero Link icon

      boolean isZero()
      Returns:
      Whether this vector is a zero vector
    • isZero Link icon

      boolean isZero(double margin)
      Returns:
      Whether the length of this vector is smaller than the given margin
    • isOnLine Link icon

      boolean isOnLine(T other, double epsilon)
      Returns:
      true if this vector is in line with the other vector (either in the same or the opposite direction)
    • isOnLine Link icon

      boolean isOnLine(T other)
      Returns:
      true if this vector is in line with the other vector (either in the same or the opposite direction)
    • isCollinear Link icon

      boolean isCollinear(T other, double epsilon)
      Returns:
      true if this vector is collinear with the other vector (isOnLine(VectorDouble, double) and hasSameDirection(VectorDouble)).
    • isCollinear Link icon

      boolean isCollinear(T other)
      Returns:
      true if this vector is collinear with the other vector (isOnLine(VectorDouble) and hasSameDirection(VectorDouble)).
    • isCollinearOpposite Link icon

      boolean isCollinearOpposite(T other, double epsilon)
      Returns:
      true if this vector is opposite collinear with the other vector (isOnLine(VectorDouble, double) and hasOppositeDirection(VectorDouble)).
    • isCollinearOpposite Link icon

      boolean isCollinearOpposite(T other)
      Returns:
      true if this vector is opposite collinear with the other vector (isOnLine(VectorDouble) and hasOppositeDirection(VectorDouble)).
    • isPerpendicular Link icon

      boolean isPerpendicular(T other)
      Returns:
      Whether this vector is perpendicular with the other vector. True if the dot product is 0.
    • isPerpendicular Link icon

      boolean isPerpendicular(T other, double epsilon)
      Parameters:
      epsilon - a positive small number close to zero
      Returns:
      Whether this vector is perpendicular with the other vector. True if the dot product is 0.
    • hasSameDirection Link icon

      boolean hasSameDirection(T other)
      Returns:
      Whether this vector has similar direction compared to the other vector. True if the normalized dot product is >0.
    • hasOppositeDirection Link icon

      boolean hasOppositeDirection(T other)
      Returns:
      Whether this vector has opposite direction compared to the other vector. True if the normalized dot product is <0.
    • epsilonEquals Link icon

      boolean epsilonEquals(T other, double epsilon)
      Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
      Parameters:
      other - The other vector.
      epsilon - The maximum deviation.
      Returns:
      whether the vectors have fuzzy equality.
    • mulAdd Link icon

      T mulAdd(T v, double scalar)
      First scale a supplied vector, then add it to this vector.
      Parameters:
      v - addition vector.
      scalar - for scaling the addition vector.
    • mulAdd Link icon

      T mulAdd(T v, T mulVec)
      First scale a supplied vector, then add it to this vector.
      Parameters:
      v - addition vector.
      mulVec - vector by whose values the addition vector will be scaled.
    • setZero Link icon

      T setZero()
      Sets the components of this vector to 0.
      Returns:
      This vector for chaining.