## Class Vector

    java.lang.Object
      Vector

    public class Vector

extends java.lang.Object

Vector - This class was written as a utility class for Greenfoot scenarios. This class represents a 2-dimensional vector. The vector can be used to deal with movement information (speed and direction) of actors. An actor can store a vector, and then other vectors can be added to modify the current velocity and direction.

Version:
  1.1 (July 2007)
Author:
  Poul Henriksen, Michael Kolling

Constructor Summary
`Vector()`
`Vector(int direction, double length)`

Method Summary
`void` | `add(Vector other)` Add other vector to this vector.
`Vector` | `copy()` Create a copy of this vector.
`int` | `getDirection()`
`double` | `getLength()`
`double` | `getX()`
`double` | `getY()`
`void` | `reduceLength(double d)`
`void` | `scale(double factor)`
`void` | `setDirection(int direction)` Set the direction of this vector.
`void` | `setNeutral()`
`java.lang.String` | `toString()`

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

Constructor Detail

### Vector

    public Vector()

### Vector

    public Vector(int direction,
                  double length)

Method Detail

### add

    public void add(Vector other)

  Add other vector to this vector.

### copy

    public Vector copy()

  Create a copy of this vector.

### getDirection

    public int getDirection()

### getLength

    public double getLength()

### getX

    public double getX()

### getY

    public double getY()

### reduceLength

    public void reduceLength(double d)

### scale

    public void scale(double factor)

### setDirection

    public void setDirection(int direction)

  Set the direction of this vector.

### setNeutral

    public void setNeutral()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`