public final class Direction
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Direction |
EAST
Direction that represents pointing east (right on screen).
|
static Direction |
NORTH
Direction that represents pointing north (up on screen).
|
float |
radians
The radians at which this direction is facing based off of
the unit circle; i.e.
|
static Direction |
SOUTH
Direction that represents pointing south (down on screen).
|
static Direction |
WEST
Direction that represents pointing west (left on screen).
|
| Constructor and Description |
|---|
Direction(float radians) |
Direction(float dx,
float dy)
Creates a new Direction instance to represent the direction
in which the vector created by dx and dy points.
|
Direction(MapLocation start,
MapLocation finish)
Creates a new Direction instance to represent the direction
in which the vector from start to finish points.
|
| Modifier and Type | Method and Description |
|---|---|
float |
degreesBetween(Direction other)
Computes the angle between the given direction and this direction in degrees.
|
boolean |
equals(Direction other,
float epsilon)
If two Directions are equal to each other, with an error range epsilon radians.
|
boolean |
equals(java.lang.Object other)
If another Direction equals this one.
|
float |
getAngleDegrees()
Computes the angle in degrees at which this direction faces.
|
float |
getDeltaX(float travelDist)
Computes the signed distance traveled on the x-axis when traveling travelDist
units in this Direction.
|
float |
getDeltaY(float travelDist)
Computes the signed distance traveled on the y-axis when traveling travelDist
units in this Direction.
|
static Direction |
getEast()
Creates a instance of Direction that represents pointing east (right on screen).
|
static Direction |
getNorth()
Creates a instance of Direction that represents pointing north (up on screen).
|
static Direction |
getSouth()
Creates a instance of Direction that represents pointing south (down on screen).
|
static Direction |
getWest()
Creates a instance of Direction that represents pointing west (left on screen).
|
int |
hashCode() |
Direction |
opposite()
Computes the direction opposite this one.
|
float |
radiansBetween(Direction other)
Computes the angle between the given direction and this direction in radians.
|
Direction |
rotateLeftDegrees(float angleDegrees)
Computes the direction angleDegrees to the left (counter-clockwise)
of this one.
|
Direction |
rotateLeftRads(float angleRads)
Computes the direction angleRads (radians) to the left (counter-clockwise)
of this one.
|
Direction |
rotateRightDegrees(float angleDegrees)
Computes the direction angleDegrees to the right (clockwise) of this
one.
|
Direction |
rotateRightRads(float angleRads)
Computes the direction angleRads (radians) to the right (clockwise) of
this one.
|
java.lang.String |
toString() |
public static final Direction NORTH
public static final Direction EAST
public static final Direction SOUTH
public static final Direction WEST
public final float radians
public Direction(float radians)
radians - the radians at which you wish this direction
to represent based off of the unit circlepublic Direction(float dx,
float dy)
dx - the x component of the vectordy - the y component of the vectorpublic Direction(MapLocation start, MapLocation finish)
start - the starting point of the vectorfinish - the ending point of the vectorpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - Another Directionpublic boolean equals(Direction other, float epsilon)
other - Another Direction.epsilon - Amount of error (in radians) to allow in the comparisonpublic static Direction getEast()
1public static Direction getNorth()
1public static Direction getWest()
1public static Direction getSouth()
1public float getDeltaX(float travelDist)
travelDist - the total distance to travel1public float getDeltaY(float travelDist)
travelDist - the total distance to travel1public float getAngleDegrees()
1public Direction opposite()
1public Direction rotateLeftDegrees(float angleDegrees)
angleDegrees - number of degrees to rotate1public Direction rotateRightDegrees(float angleDegrees)
angleDegrees - number of degrees to rotate1public Direction rotateLeftRads(float angleRads)
angleRads - number of radians to rotate1public Direction rotateRightRads(float angleRads)
angleRads - number of radians to rotate1public float radiansBetween(Direction other)
other - the direction you wish to find the angle between1public float degreesBetween(Direction other)
other - the direction you wish to find the angle between1public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object