Package drawit

Class DoubleVector

java.lang.Object
drawit.DoubleVector

public class DoubleVector
extends Object
  • Constructor Details

    • DoubleVector

      public DoubleVector​(double x, double y)
  • Method Details

    • getX

      public double getX()
    • getY

      public double getY()
    • scale

      public DoubleVector scale​(double d)
      Returns a DoubleVector object whose coordinates are obtained by multiplying this vector's coordinates by the given scale factor.
    • plus

      public DoubleVector plus​(DoubleVector other)
    • getSize

      public double getSize()
    • dotProduct

      public double dotProduct​(DoubleVector other)
      Returns the dot product of this vector and the given vector.
      Postconditions:
      result == this.getX() * other.getX() + this.getY() * other.getY()
    • crossProduct

      public double crossProduct​(DoubleVector other)
      Returns the cross product of this vector and the given vector.
      Postconditions:
      result == this.getX() * other.getY() - this.getY() * other.getX()
    • asAngle

      public double asAngle()
      Returns the angle from positive X to this vector, in radians. The angle from positive X to positive Y is Math.PI / 2; the angle from positive X to negative Y is -Math.PI / 2.

      Implementation Hint: See Math.atan2(double, double).