Package 

Class Vec2

  • All Implemented Interfaces:

    
    public final class Vec2
    
                        

    2D Vectors class

    • Constructor Detail

      • Vec2

        Vec2(Vec2 vector)
        Copy constructor.
        Parameters:
        vector - Vector to copy.
      • Vec2

        Vec2(Double direction)
        Constructs a normalised direction vector.
        Parameters:
        direction - Direction in radians.
      • Vec2

        Vec2(Double x, Double y)
        Parameters:
        x - Sets x value.
        y - Sets y value.
    • Method Detail

      • set

         final Vec2 set(Double x, Double y)

        Sets a vector to equal an x/y value and returns this.

        Parameters:
        x - x value.
        y - y value.
      • set

         final Vec2 set(Vec2 v1)

        Sets a vector to another vector and returns this.

        Parameters:
        v1 - Vector to set x/y values to.
      • copy

         final Vec2 copy()

        Copy method to return a new copy of the current instance vector.

      • unaryMinus

         final Vec2 unaryMinus()

        Negates the current instance vector and return this.

      • copyNegative

         final Vec2 copyNegative()

        Negates the current instance vector and return this.

      • add

         final Vec2 add(Vec2 v)

        Adds a vector to the current instance and return this.

        Parameters:
        v - Vector to add.
      • plus

         final Vec2 plus(Vec2 v)

        Adds a vector and the current instance vector together and returns a new vector of them added together.

        Parameters:
        v - Vector to add.
      • normal

         final Vec2 normal()

        Generates a normal of a vector. Normal facing to the right clock wise 90 degrees.

      • normalize

         final Vec2 normalize()

        Normalizes the current instance vector to length 1 and returns this.

      • distance

         final Double distance(Vec2 v)

        Finds the distance between two vectors.

        Parameters:
        v - Vector to find distance from.
      • minus

         final Vec2 minus(Vec2 v1)

        Subtract a vector from the current instance vector.

        Parameters:
        v1 - Vector to subtract.
      • cross

         final Double cross(Vec2 v1)

        Finds cross product between two vectors.

        Parameters:
        v1 - Other vector to apply cross product to
      • dot

         final Double dot(Vec2 v1)

        Finds dotproduct between two vectors.

        Parameters:
        v1 - Other vector to apply dotproduct to.
      • length

         final Double length()

        Gets the length of instance vector.