Interface Vector2d

All Known Subinterfaces:
MVector2d

public interface Vector2d
Read-only interface for handling vectors in the XY-plane.
Since:
9.10.2
  • Field Summary

    Fields
    Modifier and Type Field Description
    static Vector2d NEG_UNIT_X
    The vector (-1, 0).
    static Vector2d NEG_UNIT_Y
    The vector (0, -1).
    static Vector2d UNIT_X
    The vector (1, 0).
    static Vector2d UNIT_Y
    The vector (0, 1).
    static Vector2d ZERO
    The vector (0, 0).
  • Method Summary

    Modifier and Type Method Description
    MVector2d add​(Vector2d vector)
    Returns the sum of this vector and the given vector.
    double angle​(Vector2d vector)
    Returns the minimum angle between this vector and the given vector.
    static Vector2d create​(double x, double y)
    Returns a 2-dimensional vector with the given component values.
    static Vector2d create​(Vector2d vec)
    Returns a 2-dimensional vector with the X and Y values set to those of the given vector.
    double distance​(Vector2d other)
    Returns the distance between this vector and the other vector in the XY-plane.
    double distanceSquared​(Vector2d other)
    Returns the square of the distance between this vector and the other vector in the XY-plane.
    double dotProduct​(Vector2d vector)
    Returns the dot product between this vector and the given vector.
    boolean equalsWithTolerance​(Vector2d other, double tolerance)
    Returns true if this vector is within distance of tolerance to other.
    double getClockwiseAngle()
    This method retrieves the clockwise angle from the positive x-axis to the vector in radians.
    double getLength()
    Returns the length of this vector.
    double getLengthSquared()
    Returns the squared length of this vector.
    double getX()
    Returns the X component of this vector.
    double getY()
    Returns the Y component of this vector.
    MVector2d interpolate​(Vector2d vector, double alpha)
    Returns a vector that is the interpolation between this vector and the given vector so that the weight of the given vector is alpha (result is (1 - alpha) * this + alpha * vector).
    MVector2d negate()
    Returns a negated copy of this vector.
    MVector2d normalize()
    Returns a normalized copy of this vector.
    MVector2d scale​(double scalar)
    Returns a copy of this vector scaled by the given scalar.
    MVector2d subtract​(Vector2d vector)
    Returns the difference of this vector and the given vector.
    static List<Vector2d> to2dVectors​(List<? extends Vector3d> vectors)
    Returns the vectors in the given list projected to the XY-plane.
    MVector3d to3dVector()
    Returns a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0.
  • Field Details

    • ZERO

      static final Vector2d ZERO
      The vector (0, 0).
      Since:
      9.10.2
    • UNIT_X

      static final Vector2d UNIT_X
      The vector (1, 0).
      Since:
      9.10.2
    • NEG_UNIT_X

      static final Vector2d NEG_UNIT_X
      The vector (-1, 0).
      Since:
      9.10.2
    • UNIT_Y

      static final Vector2d UNIT_Y
      The vector (0, 1).
      Since:
      9.10.2
    • NEG_UNIT_Y

      static final Vector2d NEG_UNIT_Y
      The vector (0, -1).
      Since:
      9.10.2
  • Method Details

    • create

      static Vector2d create​(double x, double y)
      Returns a 2-dimensional vector with the given component values.
      Parameters:
      x - the value of the X component
      y - the value of the Y component
      Returns:
      a 2-dimensional vector with the given component values
      Since:
      9.10.2
    • create

      static Vector2d create​(Vector2d vec)
      Returns a 2-dimensional vector with the X and Y values set to those of the given vector.
      Parameters:
      vec - the vector used for setting the values of the created vector
      Returns:
      a 2-dimensional vector with the values set to those of the given vector
      Since:
      9.10.2
    • to2dVectors

      static List<Vector2d> to2dVectors​(List<? extends Vector3d> vectors)
      Returns the vectors in the given list projected to the XY-plane. The order of the vectors is preserved.
      Parameters:
      vectors - vectors that are projected to the XY-plane
      Returns:
      the vectors in the given list projected to the XY-plane
      Since:
      9.10.2
    • subtract

      MVector2d subtract​(Vector2d vector)
      Returns the difference of this vector and the given vector.
      Parameters:
      vector - the vector on the right side of the difference
      Returns:
      the difference of this vector and the given vector
      Since:
      9.10.2
    • add

      MVector2d add​(Vector2d vector)
      Returns the sum of this vector and the given vector.
      Parameters:
      vector - the vector that is added to this to get the returned vector
      Returns:
      the sum of this vector and the given vector
      Since:
      9.10.2
    • angle

      double angle​(Vector2d vector)
      Returns the minimum angle between this vector and the given vector.
      Parameters:
      vector - the vector between which the angle is computed
      Returns:
      the angle between this vector and the given vector
      Since:
      9.10.2
    • dotProduct

      double dotProduct​(Vector2d vector)
      Returns the dot product between this vector and the given vector.
      Parameters:
      vector - the vector with which the dot product is computed
      Returns:
      the dot product between this vector and the given vector
      Since:
      9.10.2
    • equalsWithTolerance

      boolean equalsWithTolerance​(Vector2d other, double tolerance)
      Returns true if this vector is within distance of tolerance to other.
      Parameters:
      other - the point that is compared for near equality in the XY-plane
      tolerance - the allowed distance between this vector and other
      Returns:
      true if this vector is within tolerance of other in the XY-plane
      Since:
      9.10.2
    • distance

      double distance​(Vector2d other)
      Returns the distance between this vector and the other vector in the XY-plane.
      Parameters:
      other - the vector to which the distance is computed in the XY-plane.
      Returns:
      the distance between this vector and other in the XY-plane.
      Since:
      9.10.2
    • distanceSquared

      double distanceSquared​(Vector2d other)
      Returns the square of the distance between this vector and the other vector in the XY-plane.
      Parameters:
      other - the vector to which the squared distance is computed in the XY-plane.
      Returns:
      the square of the distance between this vector and other in the XY-plane.
      Since:
      9.10.2
    • getLength

      double getLength()
      Returns the length of this vector.
      Returns:
      the length of this vector
      Since:
      9.10.2
    • getLengthSquared

      double getLengthSquared()
      Returns the squared length of this vector.
      Returns:
      the squared length of this vector
      Since:
      9.10.2
    • interpolate

      MVector2d interpolate​(Vector2d vector, double alpha)
      Returns a vector that is the interpolation between this vector and the given vector so that the weight of the given vector is alpha (result is (1 - alpha) * this + alpha * vector). Values of alpha smaller than 0 default to 0 and values greater than 1 default to 1.
      Parameters:
      vector - the vector with which this is interpolated
      alpha - the interpolation factor
      Returns:
      a vector that is the interpolation between this vector and the given vector
      Since:
      9.10.2
    • negate

      MVector2d negate()
      Returns a negated copy of this vector.
      Returns:
      a negated copy of this vector
      Since:
      9.10.2
    • normalize

      MVector2d normalize()
      Returns a normalized copy of this vector.
      Returns:
      a normalized copy of this vector
      Since:
      9.10.2
    • getX

      double getX()
      Returns the X component of this vector.
      Returns:
      the X component of this
      Since:
      9.10.2
    • getY

      double getY()
      Returns the Y component of this vector.
      Returns:
      the Y component of this
      Since:
      9.10.2
    • scale

      MVector2d scale​(double scalar)
      Returns a copy of this vector scaled by the given scalar.
      Parameters:
      scalar - the scalar by which the returned vector is scaled
      Returns:
      a copy of this vector scaled by the given scalar
    • to3dVector

      MVector3d to3dVector()
      Returns a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0.
      Returns:
      a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0
      Since:
      9.10.2
    • getClockwiseAngle

      double getClockwiseAngle()
      This method retrieves the clockwise angle from the positive x-axis to the vector in radians. It produces values in the half-open interval [0,2pi), where the positive x-axis has the value 0 and the vectors approaching the positive x-axis from the positive y-axis -side will have values close to 2pi. Zero vector will return the value 0.0.
      Returns:
      the clockwise angle from the positive x-axis to the vector
      Since:
      9.10.2