## Class Vector2D

- java.lang.Object
- - Vector2D

-     public class Vector2D
      extends java.lang.Object

  A 2D vector with components of double precision. We also think of this as a point on a 2D plane. Remark: This data structure can be used both for something that is conceptually a vector (e.g. a displacement vector) and for something that is conceptually a point on the plane (because a point can be identified with the vector from the origin to the point).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `double` | `x`
    `double` | `y`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Vector2D(double x, double y)` Constructor a Vector with components x and y.
    `Vector2D(javax.vecmath.Point2d p)` Constructor: a copy of p.
    `Vector2D(Vector2D p)` Constructor: A copy of p.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Vector2D` | `add(Vector2D a)` Return the result of adding this vector to a.
    `static Vector2D` | `add(Vector2D a, Vector2D b)` Return the result of adding a and b.
    `void` | `addOn(Vector2D v)` Add v to this vector.
    `static double` | `dist(Vector2D a, Vector2D b)` Return the Euclidean distance between points a and b.
    `Vector2D` | `minus(Vector2D b)` Return the result of subtracting b from this vector.
    `java.lang.String` | `toString()` Return a representation (x, y) of this instance.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### x

          public double x

    - #### y

          public double y

  - ### Constructor Detail

    - #### Vector2D

          public Vector2D(Vector2D p)

      Constructor: A copy of p.

    - #### Vector2D

          public Vector2D(javax.vecmath.Point2d p)

      Constructor: a copy of p.

    - #### Vector2D

          public Vector2D(double x,
                  double y)

      Constructor a Vector with components x and y.

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

      Return a representation (x, y) of this instance.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### add

          public Vector2D add(Vector2D a)

      Return the result of adding this vector to a.

    - #### add

          public static Vector2D add(Vector2D a,
                     Vector2D b)

      Return the result of adding a and b.

    - #### dist

          public static double dist(Vector2D a,
                    Vector2D b)

      Return the Euclidean distance between points a and b.

    - #### addOn

          public void addOn(Vector2D v)

      Add v to this vector.

    - #### minus

          public Vector2D minus(Vector2D b)

      Return the result of subtracting b from this vector. (don't change b; don't change this Vector).