## Class Direction

```java.lang.Object
Direction
```

`public class Directionextends java.lang.Object`

Represents a direction in the xy plane.

This class includes MANY methods of constructing and transforming directions. You can probably do all your direction calculations by calling the right method of this class!

Author:
CPSC 111 instructors

Field Summary
`static double` `FULL_CIRCLE`
Number of degrees to turn all the way around.

Constructor Summary
`Direction(double direction)`
Construct a direction at the given angle in degrees (e.g., 0 to 360 degrees, although this can handle angles outside that range).
```Direction(double x, double y)```
Construct a direction from the given vector.

Method Summary
`static Direction` `createDirectionRadians(double radians)`
Construct a direction at the given angle in radians (e.g., 0 to 2*Math.PI radians, although this can handle angles outside that range).
`static double` ```distance(double x1, double y1, double x2, double y2)```
Convenience method to calculate the distance between two given points.
` boolean` `equals(java.lang.Object obj)`

` double` `getDirection()`
Get the direction in degrees represented by this direction.
` double` `getDirectionRadians()`
Get the direction in radians represented by this direction.

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FULL_CIRCLE

`public static final double FULL_CIRCLE`
Number of degrees to turn all the way around. No surprises here.

Constant Field Values
Constructor Detail

### Direction

`public Direction(double direction)`
Construct a direction at the given angle in degrees (e.g., 0 to 360 degrees, although this can handle angles outside that range).

Parameters:
`direction` - a direction in degrees

### Direction

```public Direction(double x,
double y)```
Construct a direction from the given vector. In other words, if one object were x units right of another and y units below another, the direction from the first object to the second would be the direction constructed by this method.

This method DOES handle x and y values of 0. If BOTH are 0, this just gives a direction pointing directly right.

Parameters:
`x` - the distance in the x direction (rightward) to an object pointed to by this direction
`y` - the distance in the y direction (downward) to an object pointed to by this direction
Method Detail

### distance

```public static double distance(double x1,
double y1,
double x2,
double y2)```
Convenience method to calculate the distance between two given points.

Parameters:
`x1` - the x-coord of the first point
`y1` - the y-coord of the first point
`x2` - the x-coord of the second point
`y2` - the y-coord of the second point
Returns:
the distance between the two points

### getDirection

`public double getDirection()`
Get the direction in degrees represented by this direction.

Returns:
a direction in degrees on the range [0, 360)

`public double getDirectionRadians()`
Get the direction in radians represented by this direction.

Returns:
a direction in radians on the range [0, 2*Math.PI)

`public static Direction createDirectionRadians(double radians)`
Construct a direction at the given angle in radians (e.g., 0 to 2*Math.PI radians, although this can handle angles outside that range).

Parameters:
`radians` - a direction in radians
Returns:
the indicated direction

### equals

`public boolean equals(java.lang.Object obj)`
Overrides:
`equals` in class `java.lang.Object`