## Class Vector2

```java.lang.Object
|
+--Vector2
```
Direct Known Subclasses:
Vector2Colored

class Vector2
extends java.lang.Object

A helper class used for pairs of real numbers.

 Field Summary ` double` `x` ` double` `y`

 Constructor Summary `Vector2()` `Vector2(double angle)` ```Vector2(double ix, double iy)``` `Vector2(Vector2 u)`

 Method Summary ` void` `add(Vector2 v)` ` double` `angle()`           Returns the actual angle between -PI/2 and 3PI/2 of the vector's direction. `static double` ```angle(Vector2 u, Vector2 v)```           Returns an angle between -PI and PI expressing the turn from u to v. ` void` `copy(Vector2 v)` `static Vector2` ```difference(Vector2 u, Vector2 v)``` ` double` `distanceTo(Vector2 u)` `static double` ```dotproduct(Vector2 u, Vector2 v)``` ` double` `magnitude()` ` void` `multiply(double r)` ` boolean` `nonzero()` ` double` `normalize()` `static Vector2` ```product(double r, Vector2 u)```           Scalar product. ` void` `set(double angle)` ` void` ```set(double ix, double iy)```           Shorter name for existing Point2D setLocation method. ` double` `setMagnitude(double newmag)` ` void` `setzero()` ` void` `subtract(Vector2 v)` `static Vector2` ```sum(Vector2 u, Vector2 v)``` ` java.lang.String` `toString()` ` void` `turn(double angle)`

 Methods inherited from class java.lang.Object ```, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait```

 Field Detail

### x

`public double x`

### y

`public double y`
 Constructor Detail

### Vector2

`public Vector2()`

### Vector2

```public Vector2(double ix,
double iy)```

### Vector2

`public Vector2(Vector2 u)`

### Vector2

`public Vector2(double angle)`
 Method Detail

### sum

```public static Vector2 sum(Vector2 u,
Vector2 v)```

### difference

```public static Vector2 difference(Vector2 u,
Vector2 v)```

### product

```public static Vector2 product(double r,
Vector2 u)```
Scalar product.

### dotproduct

```public static double dotproduct(Vector2 u,
Vector2 v)```

### angle

```public static double angle(Vector2 u,
Vector2 v)```
Returns an angle between -PI and PI expressing the turn from u to v. That is, u.turn(Vector2.angle(u,v)) points in the same direction as v.

### angle

`public double angle()`
Returns the actual angle between -PI/2 and 3PI/2 of the vector's direction.

### nonzero

`public boolean nonzero()`

### copy

`public void copy(Vector2 v)`

### set

```public void set(double ix,
double iy)```
Shorter name for existing Point2D setLocation method.

### set

`public void set(double angle)`

### magnitude

`public double magnitude()`

### distanceTo

`public double distanceTo(Vector2 u)`

### setMagnitude

`public double setMagnitude(double newmag)`

### normalize

`public double normalize()`

### setzero

`public void setzero()`

### add

`public void add(Vector2 v)`

### subtract

`public void subtract(Vector2 v)`

### multiply

`public void multiply(double r)`

### turn

`public void turn(double angle)`

### toString

`public java.lang.String toString()`
Overrides:
toString in class java.lang.Object