Class RMVector

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class RMVector
    extends java.lang.Object
    implements java.lang.Cloneable
    This class represents a 2D vector.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double x  
      double y  
    • Constructor Summary

      Constructors 
      Constructor Description
      RMVector()
      Creates a new vector.
      RMVector​(double X, double Y)
      Creates a new vector.
    • Field Detail

      • x

        public double x
      • y

        public double y
    • Constructor Detail

      • RMVector

        public RMVector()
        Creates a new vector.
      • RMVector

        public RMVector​(double X,
                        double Y)
        Creates a new vector.
    • Method Detail

      • add

        public RMVector add​(double X,
                            double Y)
        Adds the vector components to this vector.
      • normalize

        public RMVector normalize()
        Normalizes the vector.
      • negate

        public RMVector negate()
        Makes this receiver point in the opposite direction.
      • multiply

        public RMVector multiply​(double aValue)
        Multiply vector by given magnitude.
      • getMagnitude

        public double getMagnitude()
        Returns the magnitude of the vector.
      • getDotProduct

        public double getDotProduct​(RMVector v2)
        Returns the dot product of the receiver and the given vector.
      • getNormalized

        public RMVector getNormalized()
        Returns the normalized vector.
      • clone

        public RMVector clone()
        Returns a basic clone of this object.
        Overrides:
        clone in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string representation of the vector.
        Overrides:
        toString in class java.lang.Object