Class Vector2i

    • Constructor Detail

      • Vector2i

        public Vector2i()
        Construct a zero vector.
      • Vector2i

        public Vector2i​(Tuple2D<?> tuple)
        Constructor by copy.
        Parameters:
        tuple - is the tuple to copy.
      • Vector2i

        public Vector2i​(int[] tuple)
        Constructor by copy.
        Parameters:
        tuple - is the tuple to copy.
      • Vector2i

        public Vector2i​(double[] tuple)
        Constructor by copy.
        Parameters:
        tuple - is the tuple to copy.
      • Vector2i

        public Vector2i​(int x,
                        int y)
        Constructor a vector with the given coordinates.
        Parameters:
        x - x coordinate.
        y - y coordinate.
      • Vector2i

        public Vector2i​(float x,
                        float y)
        Constructor a vector with the given coordinates.
        Parameters:
        x - x coordinate.
        y - y coordinate.
      • Vector2i

        public Vector2i​(double x,
                        double y)
        Constructor a vector with the given coordinates.
        Parameters:
        x - x coordinate.
        y - y coordinate.
      • Vector2i

        public Vector2i​(long x,
                        long y)
        Constructor a vector with the given coordinates.
        Parameters:
        x - x coordinate.
        y - y coordinate.
    • Method Detail

      • convert

        public static Vector2i convert​(Tuple2D<?> tuple)
        Convert the given tuple to a real Vector2i.

        If the given tuple is already a Vector2i, it is replied.

        Parameters:
        tuple - the tuple.
        Returns:
        the Vector2i.
        Since:
        14.0
      • toOrientationVector

        @Pure
        public static Vector2i toOrientationVector​(double angle)
        Replies the orientation vector, which is corresponding to the given angle on a trigonometric circle.
        Parameters:
        angle - is the angle in radians to translate.
        Returns:
        the orientation vector which is corresponding to the given angle.
      • dot

        @Pure
        public double dot​(Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Computes the dot product of the this vector and the given vector.
        Specified by:
        dot in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector - the other vector
        Returns:
        the dot product.
      • perp

        @Pure
        public double perp​(Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Compute the the perpendicular product of the two vectors (aka. the determinant of two vectors).
        det(X1, X2) = |X1|.|X2|.sin(a)
        where X1 and X2 are two vectors and a is the angle between X1 and X2.
        Specified by:
        perp in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector - the vertor.
        Returns:
        the determinant
      • getLength

        @Pure
        public double getLength()
        Description copied from interface: Vector2D
        Returns the length of this vector.
        Specified by:
        getLength in interface Vector2D<Vector2i,​Point2i>
        Returns:
        the length of this vector
      • getLengthSquared

        @Pure
        public double getLengthSquared()
        Description copied from interface: Vector2D
        Returns the squared length of this vector.
        Specified by:
        getLengthSquared in interface Vector2D<Vector2i,​Point2i>
        Returns:
        the squared length of this vector
      • add

        public void add​(Vector2D<?,​?> vector1,
                        Vector2D<?,​?> vector2)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the sum of tuples vector1 and vector2.
        Specified by:
        add in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector1 - the first tuple
        vector2 - the second tuple
      • add

        public void add​(Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the sum of itself and the given vector.
        Specified by:
        add in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector - the other tuple
      • scaleAdd

        public void scaleAdd​(int scale,
                             Vector2D<?,​?> vector1,
                             Vector2D<?,​?> vector2)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the scalar multiplication of tuple t1 plus tuple t2 (this = s*t1 + t2).
        Specified by:
        scaleAdd in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        scale - the scalar value
        vector1 - the tuple to be multipled
        vector2 - the tuple to be added
      • scaleAdd

        public void scaleAdd​(double scale,
                             Vector2D<?,​?> vector1,
                             Vector2D<?,​?> vector2)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the scalar multiplication of the tuple vector1 plus the tuple vector2 (this = s*vector1 + vector2).
        Specified by:
        scaleAdd in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        scale - the scalar value
        vector1 - the tuple to be multipled
        vector2 - the tuple to be added
      • scaleAdd

        public void scaleAdd​(int scale,
                             Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).
        Specified by:
        scaleAdd in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        scale - the scalar value
        vector - the tuple to be added
      • scaleAdd

        public void scaleAdd​(double scale,
                             Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).
        Specified by:
        scaleAdd in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        scale - the scalar value
        vector - the tuple to be added
      • sub

        public void sub​(Vector2D<?,​?> vector1,
                        Vector2D<?,​?> vector2)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the difference of tuples vector1 and vector2 (this = vector1 - vector2).
        Specified by:
        sub in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector1 - the first tuple
        vector2 - the second tuple
      • sub

        public void sub​(Point2D<?,​?> point1,
                        Point2D<?,​?> point2)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the difference of tuples point1 and point2 (this = point1 - point2).
        Specified by:
        sub in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        point1 - the first tuple
        point2 - the second tuple
      • sub

        public void sub​(Vector2D<?,​?> vector)
        Description copied from interface: Vector2D
        Sets the value of this tuple to the difference of itself and vector (this = this - vector).
        Specified by:
        sub in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        vector - the other tuple
      • setLength

        public void setLength​(double newLength)
        Description copied from interface: Vector2D
        Change the length of the vector. The direction of the vector is unchanged.
        Specified by:
        setLength in interface Vector2D<Vector2i,​Point2i>
        Parameters:
        newLength - - the new length.