Interface IVector2

  • All Known Implementing Classes:
    SynchronizedVector2Wrapper, Vector2Double, Vector2Int

    public interface IVector2
    Interface for cartesian 2-vectors NOTE: All operations on the vector are destructive and the instance returned is the same as the one whose method was called. If you require a copy of the vector before performing operations on it, use the copy constructor, the copy method or the clone interface.
    • Method Detail

      • assign

        IVector2 assign​(IVector2 vector)
        Assigns this vector the values of another vector.
        Parameters:
        vector - the other vector
        Returns:
        a reference to the called vector (NOT a copy)
      • add

        IVector2 add​(double scalar)
        Adds a scalar to each component of this vector.
        Parameters:
        scalar - scalar value as double
        Returns:
        a reference to the called vector (NOT a copy)
      • add

        IVector2 add​(IVector1 scalar)
        Adds a scalar to each component of this vector.
        Parameters:
        scalar - scalar value
        Returns:
        a reference to the called vector (NOT a copy)
      • add

        IVector2 add​(IVector2 vector)
        Adds another vector to this vector, adding individual components.
        Parameters:
        vector - the vector to add to this vector
        Returns:
        a reference to the called vector (NOT a copy)
      • subtract

        IVector2 subtract​(double scalar)
        Subtracts a scalar to each component of this vector.
        Parameters:
        scalar - scalar value as double
        Returns:
        a reference to the called vector (NOT a copy)
      • subtract

        IVector2 subtract​(IVector1 scalar)
        Subtracts a scalar to each component of this vector.
        Parameters:
        scalar - scalar value
        Returns:
        a reference to the called vector (NOT a copy)
      • subtract

        IVector2 subtract​(IVector2 vector)
        Subtracts another vector to this vector, subtracting individual components.
        Parameters:
        vector - the vector to subtract from this vector
        Returns:
        a reference to the called vector (NOT a copy)
      • mod

        IVector2 mod​(IVector2 modulus)
        Applies a modulo vector. The modulus will be added first so that values in the interval (-modulus, 0) will wrap over into the positive range.
        Parameters:
        modulus - modulus
        Returns:
        a reference to the called vector (NOT a copy)
      • multiply

        IVector2 multiply​(double scalar)
        Performs a scalar multiplication (scaling) on the vector.
        Parameters:
        scalar - the scale factor double
        Returns:
        a reference to the called vector (NOT a copy)
      • multiply

        IVector2 multiply​(IVector1 scalar)
        Performs a scalar multiplication (scaling) on the vector.
        Parameters:
        scalar - the scale factor
        Returns:
        a reference to the called vector (NOT a copy)
      • multiply

        IVector2 multiply​(IVector2 vector)
        Performs a multiplication on the vector.
        Parameters:
        vector - vector
        Returns:
        a reference to the called vector (NOT a copy)
      • divide

        IVector2 divide​(IVector2 vector)
        Performs a division on the vector.
        Parameters:
        vector - vector
        Returns:
        a reference to the called vector (NOT a copy)
      • zero

        IVector2 zero()
        Sets all vector components to zero.
        Returns:
        a reference to the called vector (NOT a copy)
      • negateX

        IVector2 negateX()
        Negates the x-component.
        Returns:
        a reference to the called vector (NOT a copy)
      • negateY

        IVector2 negateY()
        Negates the y-component.
        Returns:
        a reference to the called vector (NOT a copy)
      • negate

        IVector2 negate()
        Negates the vector by negating its components.
        Returns:
        a reference to the called vector (NOT a copy)
      • randomX

        IVector2 randomX​(IVector1 lower,
                         IVector1 upper)
        Sets the x-component to a random value in the interval [lower,upper]
        Returns:
        a reference to the called vector (NOT a copy)
      • randomY

        IVector2 randomY​(IVector1 lower,
                         IVector1 upper)
        Sets the y-component to a random value in the interval [lower,upper]
        Returns:
        a reference to the called vector (NOT a copy)
      • normalize

        IVector2 normalize()
        Converts the vector to a unit vector (normalization)
      • redirect

        IVector2 redirect​(double angle)
        Redirects the vector to a new direction, maintaining the magnitude.
        Parameters:
        angle - The new direction.
        Returns:
        The vector.
      • getInnerProductAsDouble

        double getInnerProductAsDouble​(IVector2 vector)
        Returns the length (magnitude) of the vector.
        Returns:
        vector length
      • getLength

        IVector1 getLength()
        Returns the length (magnitude) of the vector.
        Returns:
        vector length
      • getSquaredLength

        IVector1 getSquaredLength()
        Returns the squared length (magnitude) of the vector.
        Returns:
        squared vector length
      • getDirection

        IVector1 getDirection​(IVector2 vector)
        Returns the direction (theta) of the vector.
        Returns:
        vector direction
      • getDirectionAsFloat

        float getDirectionAsFloat​(IVector2 vector)
        Returns the direction (theta) of the vector as float.
        Returns:
        vector direction as float
      • getDirectionAsDouble

        double getDirectionAsDouble​(IVector2 vector)
        Returns the direction (theta) of the vector as double.
        Returns:
        vector direction as double
      • getDirection

        IVector1 getDirection()
        Returns the direction (theta) of the vector.
        Returns:
        vector direction
      • getDirectionAsFloat

        float getDirectionAsFloat()
        Returns the direction (theta) of the vector as float.
        Returns:
        vector direction as float
      • getDirectionAsDouble

        double getDirectionAsDouble()
        Returns the direction (theta) of the vector as double.
        Returns:
        vector direction as double
      • getMean

        IVector1 getMean()
        Returns the mean average of the vector components.
        Returns:
        vector direction
      • getDistance

        IVector1 getDistance​(IVector2 vector)
        Returns the distance to another vector.
        Parameters:
        vector - other vector
        Returns:
        distance
      • getX

        IVector1 getX()
        Returns the x-component of the vector.
        Returns:
        x-component
      • getY

        IVector1 getY()
        Returns the y-component of the vector.
        Returns:
        y-component
      • getXAsInteger

        int getXAsInteger()
        Returns the x-component of the vector as integer.
        Returns:
        x-component as integer
      • getYAsInteger

        int getYAsInteger()
        Returns the component of the vector as integer.
        Returns:
        y-component as float
      • getXAsLong

        long getXAsLong()
        Returns the x-component of the vector as long.
        Returns:
        x-component as long
      • getYAsLong

        long getYAsLong()
        Returns the component of the vector as float.
        Returns:
        y-component as float
      • getXAsFloat

        float getXAsFloat()
        Returns the x-component of the vector as float.
        Returns:
        x-component as float
      • getYAsFloat

        float getYAsFloat()
        Returns the component of the vector as float.
        Returns:
        y-component as float
      • getXAsDouble

        double getXAsDouble()
        Returns the x-component of the vector as double.
        Returns:
        x-component as double
      • getYAsDouble

        double getYAsDouble()
        Returns the component of the vector as double.
        Returns:
        y-component as double
      • getXAsBigDecimal

        java.math.BigDecimal getXAsBigDecimal()
        Returns the x-component of the vector as BigDecimal.
        Returns:
        x-component as BigDecimal
      • getYAsBigDecimal

        java.math.BigDecimal getYAsBigDecimal()
        Returns the component of the vector as BigDecima;.
        Returns:
        y-component as BigDecimal
      • copy

        IVector2 copy()
        Makes a copy of the vector without using the complex clone interface.
        Returns:
        copy of the vector
      • clone

        java.lang.Object clone()
                        throws java.lang.CloneNotSupportedException
        Generates a deep clone of the vector.
        Returns:
        clone of this vector
        Throws:
        java.lang.CloneNotSupportedException
      • equals

        boolean equals​(java.lang.Object obj)
        Compares the vector to an object
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object
        Returns:
        always returns false unless the object is an IVector2, in which case it is equivalent to equals(IVector vector)
      • equals

        boolean equals​(IVector2 vector)
        Compares the vector to another vector. The vectors are equal if the components are equal.
        Parameters:
        vector - the other vector
        Returns:
        true if the vectors are equal