Package org.joml

Interface Vector2dc

  • All Known Implementing Classes:
    Vector2d

    public interface Vector2dc
    Interface to a read-only view of a 2-dimensional vector of double-precision floats.
    Author:
    Kai Burjack
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Vector2d absolute​(Vector2d dest)
      Compute the absolute of each of this vector's components and store the result into dest.
      Vector2d add​(double x, double y, Vector2d dest)
      Add (x, y) to this vector and store the result in dest.
      Vector2d add​(Vector2dc v, Vector2d dest)
      Add v to this vector and store the result in dest.
      Vector2d add​(Vector2fc v, Vector2d dest)
      Add v to this vector and store the result in dest.
      double angle​(Vector2dc v)
      Return the angle between this vector and the supplied vector.
      Vector2d ceil​(Vector2d dest)
      Compute for each component of this vector the smallest (closest to negative infinity) double value that is greater than or equal to that component and is equal to a mathematical integer and store the result in dest.
      double distance​(double x, double y)
      Return the distance between this vector and (x, y).
      double distance​(Vector2dc v)
      Return the distance between this and v.
      double distance​(Vector2fc v)
      Return the distance between this and v.
      double distanceSquared​(double x, double y)
      Return the distance squared between this vector and (x, y).
      double distanceSquared​(Vector2dc v)
      Return the distance squared between this and v.
      double distanceSquared​(Vector2fc v)
      Return the distance squared between this and v.
      Vector2d div​(double x, double y, Vector2d dest)
      Divide the components of this Vector3f by the given scalar values and store the result in dest.
      Vector2d div​(double scalar, Vector2d dest)
      Divide this Vector2d by the given scalar value and store the result in dest.
      Vector2d div​(Vector2dc v, Vector2d dest)
      Divide this by v component-wise and store the result into dest.
      Vector2d div​(Vector2fc v, Vector2d dest)
      Divide this Vector2d component-wise by another Vector2f and store the result in dest.
      double dot​(Vector2dc v)
      Return the dot product of this vector and v.
      boolean equals​(double x, double y)
      Compare the vector components of this vector with the given (x, y) and return whether all of them are equal.
      boolean equals​(Vector2dc v, double delta)
      Compare the vector components of this vector with the given vector using the given delta and return whether all of them are equal within a maximum difference of delta.
      Vector2d floor​(Vector2d dest)
      Compute for each component of this vector the largest (closest to positive infinity) double value that is less than or equal to that component and is equal to a mathematical integer and store the result in dest.
      Vector2d fma​(double a, Vector2dc b, Vector2d dest)
      Add the component-wise multiplication of a * b to this vector and store the result in dest.
      Vector2d fma​(Vector2dc a, Vector2dc b, Vector2d dest)
      Add the component-wise multiplication of a * b to this vector and store the result in dest.
      double get​(int component)
      Get the value of the specified component of this vector.
      java.nio.ByteBuffer get​(int index, java.nio.ByteBuffer buffer)
      Store this vector into the supplied ByteBuffer starting at the specified absolute buffer position/index.
      java.nio.DoubleBuffer get​(int index, java.nio.DoubleBuffer buffer)
      Store this vector into the supplied DoubleBuffer starting at the specified absolute buffer position/index.
      Vector2i get​(int mode, Vector2i dest)
      Set the components of the given vector dest to those of this vector using the given RoundingMode.
      java.nio.ByteBuffer get​(java.nio.ByteBuffer buffer)
      Store this vector into the supplied ByteBuffer at the current buffer position.
      java.nio.DoubleBuffer get​(java.nio.DoubleBuffer buffer)
      Store this vector into the supplied DoubleBuffer at the current buffer position.
      Vector2d get​(Vector2d dest)
      Set the components of the given vector dest to those of this vector.
      Vector2f get​(Vector2f dest)
      Set the components of the given vector dest to those of this vector.
      Vector2dc getToAddress​(long address)
      Store this vector at the given off-heap memory address.
      boolean isFinite()
      Determine whether all components are finite floating-point values, that is, they are not NaN and not infinity.
      double length()
      Return the length of this vector.
      double lengthSquared()
      Return the length squared of this vector.
      Vector2d lerp​(Vector2dc other, double t, Vector2d dest)
      Linearly interpolate this and other using the given interpolation factor t and store the result in dest.
      Vector2d max​(Vector2dc v, Vector2d dest)
      Set the components of dest to be the component-wise maximum of this and the other vector.
      int maxComponent()
      Determine the component with the biggest absolute value.
      Vector2d min​(Vector2dc v, Vector2d dest)
      Set the components of dest to be the component-wise minimum of this and the other vector.
      int minComponent()
      Determine the component with the smallest (towards zero) absolute value.
      Vector2d mul​(double x, double y, Vector2d dest)
      Multiply the components of this Vector2d by the given scalar values and store the result in dest.
      Vector2d mul​(double scalar, Vector2d dest)
      Multiply the components of this vector by the given scalar and store the result in dest.
      Vector2d mul​(Matrix2dc mat, Vector2d dest)
      Multiply the given matrix mat with this and store the result in dest.
      Vector2d mul​(Matrix2fc mat, Vector2d dest)
      Multiply the given matrix mat with this and store the result in dest.
      Vector2d mul​(Vector2dc v, Vector2d dest)
      Multiply this Vector2d component-wise by another Vector2d and store the result in dest.
      Vector2d mulDirection​(Matrix3x2dc mat, Vector2d dest)
      Multiply the given 3x2 matrix mat with this and store the result in dest.
      Vector2d mulPosition​(Matrix3x2dc mat, Vector2d dest)
      Multiply the given 3x2 matrix mat with this and store the result in dest.
      Vector2d mulTranspose​(Matrix2dc mat, Vector2d dest)
      Multiply the transpose of the given matrix with this Vector2f and store the result in dest.
      Vector2d mulTranspose​(Matrix2fc mat, Vector2d dest)
      Multiply the transpose of the given matrix with this Vector2f and store the result in dest.
      Vector2d negate​(Vector2d dest)
      Negate this vector and store the result in dest.
      Vector2d normalize​(double length, Vector2d dest)
      Scale this vector to have the given length and store the result in dest.
      Vector2d normalize​(Vector2d dest)
      Normalize this vector and store the result in dest.
      Vector2d round​(Vector2d dest)
      Compute for each component of this vector the closest double that is equal to a mathematical integer, with ties rounding to positive infinity and store the result in dest.
      Vector2d sub​(double x, double y, Vector2d dest)
      Subtract (x, y) from this vector and store the result in dest.
      Vector2d sub​(Vector2dc v, Vector2d dest)
      Subtract v from this vector and store the result in dest.
      Vector2d sub​(Vector2fc v, Vector2d dest)
      Subtract v from this vector and store the result in dest.
      double x()  
      double y()  
    • Method Detail

      • x

        double x()
        Returns:
        the value of the x component
      • y

        double y()
        Returns:
        the value of the y component
      • get

        java.nio.ByteBuffer get​(java.nio.ByteBuffer buffer)
        Store this vector into the supplied ByteBuffer at the current buffer position.

        This method will not increment the position of the given ByteBuffer.

        In order to specify the offset into the ByteBuffer at which the vector is stored, use get(int, ByteBuffer), taking the absolute position as parameter.

        Parameters:
        buffer - will receive the values of this vector in x, y order
        Returns:
        the passed in buffer
        See Also:
        get(int, ByteBuffer)
      • get

        java.nio.ByteBuffer get​(int index,
                                java.nio.ByteBuffer buffer)
        Store this vector into the supplied ByteBuffer starting at the specified absolute buffer position/index.

        This method will not increment the position of the given ByteBuffer.

        Parameters:
        index - the absolute position into the ByteBuffer
        buffer - will receive the values of this vector in x, y order
        Returns:
        the passed in buffer
      • get

        java.nio.DoubleBuffer get​(java.nio.DoubleBuffer buffer)
        Store this vector into the supplied DoubleBuffer at the current buffer position.

        This method will not increment the position of the given DoubleBuffer.

        In order to specify the offset into the DoubleBuffer at which the vector is stored, use get(int, DoubleBuffer), taking the absolute position as parameter.

        Parameters:
        buffer - will receive the values of this vector in x, y order
        Returns:
        the passed in buffer
        See Also:
        get(int, DoubleBuffer)
      • get

        java.nio.DoubleBuffer get​(int index,
                                  java.nio.DoubleBuffer buffer)
        Store this vector into the supplied DoubleBuffer starting at the specified absolute buffer position/index.

        This method will not increment the position of the given DoubleBuffer.

        Parameters:
        index - the absolute position into the DoubleBuffer
        buffer - will receive the values of this vector in x, y order
        Returns:
        the passed in buffer
      • getToAddress

        Vector2dc getToAddress​(long address)
        Store this vector at the given off-heap memory address.

        This method will throw an UnsupportedOperationException when JOML is used with `-Djoml.nounsafe`.

        This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.

        Parameters:
        address - the off-heap address where to store this vector
        Returns:
        this
      • sub

        Vector2d sub​(double x,
                     double y,
                     Vector2d dest)
        Subtract (x, y) from this vector and store the result in dest.
        Parameters:
        x - the x component to subtract
        y - the y component to subtract
        dest - will hold the result
        Returns:
        dest
      • sub

        Vector2d sub​(Vector2dc v,
                     Vector2d dest)
        Subtract v from this vector and store the result in dest.
        Parameters:
        v - the vector to subtract
        dest - will hold the result
        Returns:
        dest
      • sub

        Vector2d sub​(Vector2fc v,
                     Vector2d dest)
        Subtract v from this vector and store the result in dest.
        Parameters:
        v - the vector to subtract
        dest - will hold the result
        Returns:
        dest
      • mul

        Vector2d mul​(double scalar,
                     Vector2d dest)
        Multiply the components of this vector by the given scalar and store the result in dest.
        Parameters:
        scalar - the value to multiply this vector's components by
        dest - will hold the result
        Returns:
        dest
      • mul

        Vector2d mul​(double x,
                     double y,
                     Vector2d dest)
        Multiply the components of this Vector2d by the given scalar values and store the result in dest.
        Parameters:
        x - the x component to multiply this vector by
        y - the y component to multiply this vector by
        dest - will hold the result
        Returns:
        dest
      • mul

        Vector2d mul​(Vector2dc v,
                     Vector2d dest)
        Multiply this Vector2d component-wise by another Vector2d and store the result in dest.
        Parameters:
        v - the vector to multiply by
        dest - will hold the result
        Returns:
        dest
      • div

        Vector2d div​(double scalar,
                     Vector2d dest)
        Divide this Vector2d by the given scalar value and store the result in dest.
        Parameters:
        scalar - the scalar to divide this vector by
        dest - will hold the result
        Returns:
        dest
      • div

        Vector2d div​(double x,
                     double y,
                     Vector2d dest)
        Divide the components of this Vector3f by the given scalar values and store the result in dest.
        Parameters:
        x - the x component to divide this vector by
        y - the y component to divide this vector by
        dest - will hold the result
        Returns:
        dest
      • div

        Vector2d div​(Vector2fc v,
                     Vector2d dest)
        Divide this Vector2d component-wise by another Vector2f and store the result in dest.
        Parameters:
        v - the vector to divide by
        dest - will hold the result
        Returns:
        dest
      • div

        Vector2d div​(Vector2dc v,
                     Vector2d dest)
        Divide this by v component-wise and store the result into dest.
        Parameters:
        v - the vector to divide by
        dest - will hold the result
        Returns:
        dest
      • mul

        Vector2d mul​(Matrix2dc mat,
                     Vector2d dest)
        Multiply the given matrix mat with this and store the result in dest.
        Parameters:
        mat - the matrix to multiply this vector by
        dest - will hold the result
        Returns:
        dest
      • mul

        Vector2d mul​(Matrix2fc mat,
                     Vector2d dest)
        Multiply the given matrix mat with this and store the result in dest.
        Parameters:
        mat - the matrix to multiply this vector by
        dest - will hold the result
        Returns:
        dest
      • mulTranspose

        Vector2d mulTranspose​(Matrix2dc mat,
                              Vector2d dest)
        Multiply the transpose of the given matrix with this Vector2f and store the result in dest.
        Parameters:
        mat - the matrix
        dest - will hold the result
        Returns:
        dest
      • mulTranspose

        Vector2d mulTranspose​(Matrix2fc mat,
                              Vector2d dest)
        Multiply the transpose of the given matrix with this Vector2f and store the result in dest.
        Parameters:
        mat - the matrix
        dest - will hold the result
        Returns:
        dest
      • mulPosition

        Vector2d mulPosition​(Matrix3x2dc mat,
                             Vector2d dest)
        Multiply the given 3x2 matrix mat with this and store the result in dest.

        This method assumes the z component of this to be 1.0.

        Parameters:
        mat - the matrix to multiply this vector by
        dest - will hold the result
        Returns:
        dest
      • mulDirection

        Vector2d mulDirection​(Matrix3x2dc mat,
                              Vector2d dest)
        Multiply the given 3x2 matrix mat with this and store the result in dest.

        This method assumes the z component of this to be 0.0.

        Parameters:
        mat - the matrix to multiply this vector by
        dest - will hold the result
        Returns:
        dest
      • dot

        double dot​(Vector2dc v)
        Return the dot product of this vector and v.
        Parameters:
        v - the other vector
        Returns:
        the dot product
      • angle

        double angle​(Vector2dc v)
        Return the angle between this vector and the supplied vector.
        Parameters:
        v - the other vector
        Returns:
        the angle, in radians
      • lengthSquared

        double lengthSquared()
        Return the length squared of this vector.
        Returns:
        the length squared
      • length

        double length()
        Return the length of this vector.
        Returns:
        the length
      • distance

        double distance​(Vector2dc v)
        Return the distance between this and v.
        Parameters:
        v - the other vector
        Returns:
        the distance
      • distanceSquared

        double distanceSquared​(Vector2dc v)
        Return the distance squared between this and v.
        Parameters:
        v - the other vector
        Returns:
        the distance squared
      • distance

        double distance​(Vector2fc v)
        Return the distance between this and v.
        Parameters:
        v - the other vector
        Returns:
        the distance
      • distanceSquared

        double distanceSquared​(Vector2fc v)
        Return the distance squared between this and v.
        Parameters:
        v - the other vector
        Returns:
        the distance squared
      • distance

        double distance​(double x,
                        double y)
        Return the distance between this vector and (x, y).
        Parameters:
        x - the x component of the other vector
        y - the y component of the other vector
        Returns:
        the euclidean distance
      • distanceSquared

        double distanceSquared​(double x,
                               double y)
        Return the distance squared between this vector and (x, y).
        Parameters:
        x - the x component of the other vector
        y - the y component of the other vector
        Returns:
        the euclidean distance squared
      • normalize

        Vector2d normalize​(Vector2d dest)
        Normalize this vector and store the result in dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • normalize

        Vector2d normalize​(double length,
                           Vector2d dest)
        Scale this vector to have the given length and store the result in dest.
        Parameters:
        length - the desired length
        dest - will hold the result
        Returns:
        dest
      • add

        Vector2d add​(double x,
                     double y,
                     Vector2d dest)
        Add (x, y) to this vector and store the result in dest.
        Parameters:
        x - the x component to add
        y - the y component to add
        dest - will hold the result
        Returns:
        dest
      • add

        Vector2d add​(Vector2dc v,
                     Vector2d dest)
        Add v to this vector and store the result in dest.
        Parameters:
        v - the vector to add
        dest - will hold the result
        Returns:
        dest
      • add

        Vector2d add​(Vector2fc v,
                     Vector2d dest)
        Add v to this vector and store the result in dest.
        Parameters:
        v - the vector to add
        dest - will hold the result
        Returns:
        dest
      • negate

        Vector2d negate​(Vector2d dest)
        Negate this vector and store the result in dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • lerp

        Vector2d lerp​(Vector2dc other,
                      double t,
                      Vector2d dest)
        Linearly interpolate this and other using the given interpolation factor t and store the result in dest.

        If t is 0.0 then the result is this. If the interpolation factor is 1.0 then the result is other.

        Parameters:
        other - the other vector
        t - the interpolation factor between 0.0 and 1.0
        dest - will hold the result
        Returns:
        dest
      • fma

        Vector2d fma​(Vector2dc a,
                     Vector2dc b,
                     Vector2d dest)
        Add the component-wise multiplication of a * b to this vector and store the result in dest.
        Parameters:
        a - the first multiplicand
        b - the second multiplicand
        dest - will hold the result
        Returns:
        dest
      • fma

        Vector2d fma​(double a,
                     Vector2dc b,
                     Vector2d dest)
        Add the component-wise multiplication of a * b to this vector and store the result in dest.
        Parameters:
        a - the first multiplicand
        b - the second multiplicand
        dest - will hold the result
        Returns:
        dest
      • min

        Vector2d min​(Vector2dc v,
                     Vector2d dest)
        Set the components of dest to be the component-wise minimum of this and the other vector.
        Parameters:
        v - the other vector
        dest - will hold the result
        Returns:
        dest
      • max

        Vector2d max​(Vector2dc v,
                     Vector2d dest)
        Set the components of dest to be the component-wise maximum of this and the other vector.
        Parameters:
        v - the other vector
        dest - will hold the result
        Returns:
        dest
      • maxComponent

        int maxComponent()
        Determine the component with the biggest absolute value.
        Returns:
        the component index, within [0..1]
      • minComponent

        int minComponent()
        Determine the component with the smallest (towards zero) absolute value.
        Returns:
        the component index, within [0..1]
      • get

        double get​(int component)
            throws java.lang.IllegalArgumentException
        Get the value of the specified component of this vector.
        Parameters:
        component - the component, within [0..1]
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if component is not within [0..1]
      • get

        Vector2i get​(int mode,
                     Vector2i dest)
        Set the components of the given vector dest to those of this vector using the given RoundingMode.
        Parameters:
        mode - the RoundingMode to use
        dest - will hold the result
        Returns:
        dest
      • get

        Vector2f get​(Vector2f dest)
        Set the components of the given vector dest to those of this vector.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • get

        Vector2d get​(Vector2d dest)
        Set the components of the given vector dest to those of this vector.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • floor

        Vector2d floor​(Vector2d dest)
        Compute for each component of this vector the largest (closest to positive infinity) double value that is less than or equal to that component and is equal to a mathematical integer and store the result in dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • ceil

        Vector2d ceil​(Vector2d dest)
        Compute for each component of this vector the smallest (closest to negative infinity) double value that is greater than or equal to that component and is equal to a mathematical integer and store the result in dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • round

        Vector2d round​(Vector2d dest)
        Compute for each component of this vector the closest double that is equal to a mathematical integer, with ties rounding to positive infinity and store the result in dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • isFinite

        boolean isFinite()
        Determine whether all components are finite floating-point values, that is, they are not NaN and not infinity.
        Returns:
        true if all components are finite floating-point values; false otherwise
      • absolute

        Vector2d absolute​(Vector2d dest)
        Compute the absolute of each of this vector's components and store the result into dest.
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • equals

        boolean equals​(Vector2dc v,
                       double delta)
        Compare the vector components of this vector with the given vector using the given delta and return whether all of them are equal within a maximum difference of delta.

        Please note that this method is not used by any data structure such as ArrayList HashSet or HashMap and their operations, such as ArrayList.contains(Object) or HashSet.remove(Object), since those data structures only use the Object.equals(Object) and Object.hashCode() methods.

        Parameters:
        v - the other vector
        delta - the allowed maximum difference
        Returns:
        true whether all of the vector components are equal; false otherwise
      • equals

        boolean equals​(double x,
                       double y)
        Compare the vector components of this vector with the given (x, y) and return whether all of them are equal.
        Parameters:
        x - the x component to compare to
        y - the y component to compare to
        Returns:
        true if all the vector components are equal